Skip to content

Bug: Filter passes query validation, but the filter is not applied #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bart-degreed opened this issue Dec 20, 2019 · 4 comments · Fixed by #752
Closed

Bug: Filter passes query validation, but the filter is not applied #659

bart-degreed opened this issue Dec 20, 2019 · 4 comments · Fixed by #752

Comments

@bart-degreed
Copy link
Contributor

Description

Consider the request:

/documents/1?include=collaborators&filter[collaborators.first-name]=like:john

This request passes query validation, but the filter is not applied. It returns all collaborators. This is likely caused by EF Core not supporting filtered includes. In contrast, the next request:

/documents/1/collaborators?filter[first-name]=like:john

returns the next error message:

Query parameter filter is currently not supported on nested resource endpoints (i.e. of the form '/article/1/author?filter=...'

which is helpful. I think the fix would be to return the same error message in this case, instead of silently ignoring the filter.

Environment

v4.0.0-alpha4

@bart-degreed
Copy link
Contributor Author

I was looking into fixing this, but unfortunately the error is raised from within the query string parsing logic. Since I'm actually using the nested filtering construct for Elasticsearch-based resources (non-Entity Framework Core), I'll leave the bug in for now.

@maurei
Copy link
Member

maurei commented Feb 12, 2020

This should be a fairly easy issue to pick up for anyone out there looking to make a first contribution. Indeed, it looks like a validation issue in the corresponding IQueryParameterService implementation.

@bart-degreed
Copy link
Contributor Author

For my use case, it is unfortunate that the query validation logic is implemented apart from the resource-specific service that can or cannot provide nested includes. To overcome that, the IResourceService would need to have some mechanism to expose its capabilities.

I haven't tried, but maybe we can add a capabilities property to IFilterService or its base, and then have IResourceService assign that from its constructor.

@bart-degreed
Copy link
Contributor Author

bart-degreed commented May 13, 2020

This works correctly for 1-to-1 relationships, but crashes on 1-to-many.

filtered: /articles?include=author&filter[author.firstName]=John
crash: /blogs?include=articles&filter[articles.title]=like:art

In addition to this, the filtering pass does not execute when getting by ID.

discarded: /articles/1?include=author&filter[author.firstName]=John
discarded: /blogs/1?include=articles&filter[articles.title]=like:art

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants