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

bug: subject helper error #912

Open
Nishchit14 opened this issue May 8, 2024 · 1 comment
Open

bug: subject helper error #912

Nishchit14 opened this issue May 8, 2024 · 1 comment
Labels

Comments

@Nishchit14
Copy link

Describe the bug
When I use subject helper multiple time in the same function to check multiple permission then it's showing error

ability.can('create', subject('folder', {}));
ability.can('read', subject('chat',{}));

Error

Error: Trying to cast object to subject type chat but previously it was casted to folder

CASL Version

@casl/ability - v6.7.1

Environment:
Nodejs version v21

@Nishchit14 Nishchit14 added the bug label May 8, 2024
@Nishchit14 Nishchit14 changed the title Trying to cast object to subject type user but previously it was casted to folder bug: subject helper error May 8, 2024
@stalniy
Copy link
Owner

stalniy commented May 10, 2024

Cannot reproduce, If you look into code this error is thrown only if you try to change the type of previously used object - https://github.com/stalniy/casl/blob/master/packages/casl-ability/src/utils.ts#L25

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

No branches or pull requests

2 participants