Skip to content
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

parseFilter incorrectly converts entry names starting with item__ to item: #22502

Open
hanneskuettner opened this issue May 15, 2024 · 0 comments

Comments

@hanneskuettner
Copy link
Contributor

hanneskuettner commented May 15, 2024

Describe the Bug

The parseFilter utility function always converts filter entry names that start with item__ and are objects to item::

} else if (String(key).startsWith('item__') && isObjectLike(value)) {
return { [`item:${String(key).split('item__')[1]}`]: parseFilter(value, accountability, context) } as Filter;

This could potentially lead to problems when the user actually has a field named item__<something> and wants to filter that field. This conversion was initially introduced in #15162 as fix to not being able to filter M2A relations in GraphQL.

This functionality needs to be retained, but either pulled out of parseFilter or only optionally apply, if we know that the filters are coming from GraphQL (and are actually within a M2A? Cause otherwise the same problem persists in GraphQL. Or that is then just an inherent restriction of GraphQL, similar to reserved keywords or collections starting with underscore).

Additionally, this simple replacement breaks if the user uses a different field name, other than item in their M2A relation setup.

To Reproduce

N/A

Directus Version

v10.11.0

Hosting Strategy

Self-Hosted (Docker Image)

Database

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant