strapi
strapi copied to clipboard
GraphQl returns "Invalid parameter X" on any filter
Bug report
Required System information
Node.js version: v18.17.1 YARN version: 1.22.19 Strapi version: 4.13.3 Database: SQLITE Operating system: Windows 10 Is your project Javascript or Typescript: JavaScript
Describe the bug
Unable to resolve graphql queries having "filter" property
Steps to reproduce the behavior
- Trying to get data form table products with this query:
#import "/apollo/fragments/shared/Technical.graphql"
query products(
$locale: I18NLocaleCode
$limit: Int!
$start: Int!
$brands: [String!]
$categories: [String!]
$slug: String
$id: ID
$ids: [ID]
$notSlug: String
$notId: ID
$name: String
$priceMinimal: Float
$priceMaximal: Float
$bestseller: Boolean
$sale: Boolean
$novelty: Boolean
) {
products(
locale: $locale
pagination: { start: $start, limit: $limit }
sort: "createdAt:desc"
filters: {
id: { eq: $id, in: $ids, ne: $notId }
slug: { eq: $slug, ne: $notSlug }
name: { containsi: $name }
brand: { slug: { in: $brands } }
categories: { slug: { in: $categories } }
price: { between: [$priceMinimal, $priceMaximal] }
active: { eq: true }
technical: {
novelty: { eq: $novelty }
sale: { eq: $sale }
bestseller: { eq: $bestseller }
}
}
) {
data {
id
attributes {
name
slug
status
price
priceSale
gallery {
data {
attributes {
formats
url
caption
alternativeText
}
}
}
picture {
data {
attributes {
formats
url
caption
alternativeText
}
}
}
brand {
data {
attributes {
name
slug
}
}
}
categories {
data {
id
attributes {
name
slug
}
}
}
technical {
...Technical
}
}
}
meta {
pagination {
total
page
pageCount
pageSize
}
}
}
}
- Sending params in my request:
{
"limit": 12,
"start": 0,
"locale": "en",
"priceMinimal": 0,
"priceMaximal": 99999
}
- Getting an error:
"message": "Invalid parameter id",
Expected behavior
Receiving an answer from the server which contains data[] with product information.
Additional context
Then I remove filter { } from the query - everything works fine.
schema.graphql contains the needed fields of course:
input ProductFiltersInput {
active: BooleanFilterInput
and: [ProductFiltersInput]
announcement: StringFilterInput
brand: BrandFiltersInput
categories: CategoryFiltersInput
createdAt: DateTimeFilterInput
description: StringFilterInput
features: ComponentSharedFeatureFiltersInput
id: IDFilterInput
locale: StringFilterInput
localizations: ProductFiltersInput
name: StringFilterInput
not: ProductFiltersInput
or: [ProductFiltersInput]
price: FloatFilterInput
priceSale: FloatFilterInput
publishedAt: DateTimeFilterInput
seo: ComponentSharedSeoFiltersInput
sitemap_exclude: BooleanFilterInput
slug: StringFilterInput
status: StringFilterInput
technical: ComponentSharedTechnicalFiltersInput
updatedAt: DateTimeFilterInput
}
+1
I have managed that issue by downgrading Strapi version to 4.12.4. Same as the @strapi/plugin-graphql.
I also have this issue with Strapi version 4.13.4 , I use $notIn filter and provide an empty array
Encountering same issue with filters ($in) and sort
we are also having the same issue. We use 4.13.2. For us, it is a critical bug because pages, that are using the filtering, are not working now.
Same!
I guess it's the same bug as mine. https://github.com/strapi/strapi/issues/17945 Strapi needs to solve this
Hello, everyone. I'm also experiencing issues with the filters. If I include an optional variable but don't send it to the query, it returns as an invalid value. However, in certain situations, such as during the initial rendering of a page, I don't want to apply all the filters. This used to work correctly before the update.
@derrickmehaffy Are you guys going to solve this? The issue starts to be critical.
I haven't been able to update Strapi to the latest version for several weeks now because of multiple critical bugs in the updates that break basic functionality such as this. I'm starting to get worried about the future of Strapi. Perhaps it would be a good idea to have some kind of intervention to get these issues fixed. Maybe a freeze on all new feature development until the most critical issues are resolved.
Could you say something if you are working on it, so many people have this issue. It's a critical bug
Hello !
Same issue here, all our filtered listing are broken with latest version (4.13.7). So we are stuck to 4.12.1 for several weeks.
I hope this critical issue to get solved in priority π
Could you say something if you are working on it, so many people have this issue. It's a critical bug
Working on it right now. I don't think we will be able to make it into the release tomorrow (though I will try) but it should certainly be in next week's release!
Escalated due to internal tid 4884
Jumping it up to critical based on internal discussion
The reason for this is that queries are being sent with optional variables being used in query params, for example, filters: { id: { eq: $id } } becomes filters: { id: { } } when id is not sent, which is not a valid query. Newer versions of Strapi throw errors on invalid queries to help catch security issues and other bugs in user code. But in this particular instance, params that are optionally not sent, I agree it should work as an exception.
We currently have two solutions, both of which should allow your queries to work again, we are just discussing which one is the best to go with. It would be great if anyone having this problem could test them to see if it resolves your issues.
- We can allow empty object params in only GraphQL, which would introduce a subtle difference between the rest API and graphql API
- We can allow them everywhere
We're currently deciding the best path and will try to release a fix as soon as we're sure it is the right one and will not introduce any other issues.
The reason for this is that queries are being sent with optional variables being used in query params, for example,
filters: { id: { eq: $id } }becomesfilters: { id: { } }when id is not sent, which is not a valid query. Newer versions of Strapi throw errors on invalid queries to help catch security issues and other bugs in user code. But in this particular instance, params that are optionally not sent, I agree it should work as an exception.We currently have two solutions, both of which should allow your queries to work again, we are just discussing which one is the best to go with. It would be great if anyone having this problem could test them to see if it resolves your issues.
- We can allow empty object params in only GraphQL, which would introduce a subtle difference between the rest API and graphql API
- We can allow them everywhere
We're currently deciding the best path and will try to release a fix as soon as we're sure it is the right one and will not introduce any other issues.
My opinion is allowing empty object params both in GraphQL and REST API would be the right solution.
Great that you finally paid attention to that bug. Hope you'll manage this ASAP.
I don't know if you are aware of this, but the issue is still remaining with Boolean filters.
query getPrintrollMeasurement($id: ID!, $rubOffFilter: Boolean) {
printrollMeasurement(id: $id) {
data {
id
attributes {
printrollctx(
pagination: { pageSize: 20 }
filters: { rubOff: { notNull: $rubOffFilter } }
) {
id
rubOff
}
}
}
}
}
In our case, we are using the notNull filter and the answer is still:
"message": "Invalid parameter rubOffFilter",
After we remove the filter, everything is working fine.
We are still using v4.12.1 because in v4.14.4 pages, that are using this filter, are not working now.
not just with booleans, I get the same with every other type. In my case String. Nothing has been solved
I'll reopen this since it appears only the original test case was solved but there is still something to solve here.
It should be safe to allow nil values through the validator since they will be either sanitized out or accepted and ignored.
And as a side note, we're currently working on v5 and making this entire process much safer and simpler for everyone π
hello +1 same issue this several Strapi Versions so we can't upgrade to strapi v13/14/15 so far... please kindly fix it
This issue is also a blocker for us...when can we expect a fix?
Hello, We are also waiting for this fix. Currently we are still blocked in v4.7 because of this bug fixed in v4.12 but we cannot upgrade to v4.12 because of this issue. Thanks in advance
I should have time to work on a fix this week, once I have a PR available I will link it here to keep everyone updated.
I should have time to work on a fix this week, once I have a PR available I will link it here to keep everyone updated.
Thank you. If you would have some troubles with managing this issue - give me a sign. I'll help if been able.
#18647 should fix it. I need to confirm the issue is only present with components and not with relations or dynamic zones, and then we can merge :)
I saw this was merged to main. Do we have an eta no when it will be fixed in a versioned release?
I saw this was merged to main. Do we have an eta no when it will be fixed in a versioned release?
Hey, we have releases coming out every Wednesday, this fix should have been shipped in 4.15.2 (two days ago)
It seems that problem still exist on 4.15.4
I wonder why this error reoccurs over and over again. Many people affected by it too. :(