I'm learning MLOps and building a small FastAPI app that loads patient data from a JSON file. I created endpoints and query parameters to filter and sort the data, but the response always comes back in the default order. For example, I'm testing `/sort?sort_by=height&order=asc`, but changing the sorting values doesn't seem to affect the output. I also expected invalid values to raise an exception, but they're accepted without any visible error. What could be causing the endpoint to ignore the query parameters?
2 Answers
Make sure you’re calling the sorting endpoint itself, such as `/sort?sort_by=height&order=asc`, rather than another endpoint that doesn’t define those query parameters. Also check that the server is running the current version of the code instead of an older process or stale build.
An ascending sort may look unchanged if the input data is already in ascending order. Try `order=desc` and compare the first and last records. Also, an invalid value will only raise an exception if the endpoint explicitly validates it—for example, with an enum, constrained parameter, or manual check. Without validation, FastAPI may simply accept the string and your sorting logic may fall back to its default behavior.
I tried descending order and several other values, but the response still appears to use the default ordering.

I’m calling `/sort?sort_by=height&order=asc`, but changing the values still gives me the same default ordering, and values outside the expected conditions don’t produce an error.