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

using $exists in casl using createMongoAbility throws error (knex) #111

Closed
jd1378 opened this issue Mar 15, 2024 · 1 comment
Closed

using $exists in casl using createMongoAbility throws error (knex) #111

jd1378 opened this issue Mar 15, 2024 · 1 comment

Comments

@jd1378
Copy link

jd1378 commented Mar 15, 2024

This issue happens with knex adaptor

when defining an ability using createMongoAbility, the authorize hook does not take $exists into consideration. it took me a long time to understand that feathers-casl is responsible for handling this.

Expected behavior

handle $exists for the fields at hook level, not database, which makes it faster and universal.

Actual behavior

throws BadRequest: Invalid query parameter $exists which seems to be working with mongo db only.

edit: I have not confirmed that it works with mongodb, it's just a guess from what it seems

System configuration

{
  "@casl/ability": "6.7.0",
  "@feathersjs/*": "5.0.24",
  "feathers-casl": "2.1.1"
}

More Info

when basic check happens inside authorizeBefore it probably doesn't need to pass $exists to the query, as the $exists is for the incoming request, not the actual data (correct me if I'm wrong)

so we need to clean it up before it reaches the query I guess?

Possible workaround

Simply ignoring using $exists and create an inverted rule restricting the troublesome fields
edit:it seems nothing can replace the $exists operator for making sure that a property is not set
edit2: availableFields plays an important role in making this workaround work, which is fine but not ideal

@jd1378
Copy link
Author

jd1378 commented Mar 22, 2024

I became aware of usePatchData and useUpdateData

@jd1378 jd1378 closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant