fastapi-filters icon indicating copy to clipboard operation
fastapi-filters copied to clipboard

Problem with commas in filter value when using field[in]=value

Open vkuzmov opened this issue 3 months ago • 4 comments

I'm running into an issue where filter values that contain commas (,) are not being parsed correctly.

Specifically, if I use a filter value with a comma by itself, it doesn't get parsed as expected:

Image

However, if I add another filter (one that doesn't contain a comma), then the original filter with the comma is parsed correctly:

Image

Here's what the FastAPI server logs show:

Image

Is there a workaround for this issue?

vkuzmov avatar Sep 11 '25 09:09 vkuzmov

Hi @uriyyo, I can see that you've assigned the question label. Do you need any further information on this?

vkuzmov avatar Sep 13 '25 05:09 vkuzmov

Hi @vkuzmov,

Sorry for long response, I didn't thought about this use-case while I was implementing this feature.

For now you can just pass every value as a separate main_industry[in] query param, and FastAPI should correctly resolve it:

GET / endpoint?main_industry[in]=1&main_industry[in]=2&main_industry[in]=3

Let me know if it helped you 🙏

uriyyo avatar Sep 13 '25 16:09 uriyyo

Scalar values work well, but issues arise when the value is a string that contains a comma. To work around this, I'm currently using slugs for industry names, like so:

GET / endpoint?main_industry[in]=agriculture-forestry-and-fishing&main_industry[in]=healthcare-and-pharmaceuticals

vkuzmov avatar Sep 19 '25 14:09 vkuzmov

@vkuzmov Unfortunately, there is no workaroud for now, I will try to fix this issue ASAP

uriyyo avatar Sep 19 '25 15:09 uriyyo