Skip to content

Conversation

jpizquierdo
Copy link
Contributor

Change error 400 to error 403 when not enough permissions when requesting items. I think it is better a 403 than a 400 (bad request).

Change error 400 to error 403 when not enough permissions when requesting items
updated tests
Copy link

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

For users we already return status code 403

if not current_user.is_superuser:
raise HTTPException(
status_code=403,
detail="The user doesn't have enough privileges",
)

@jpizquierdo, thanks!

I think we don't need to change frontend to reflect these changes right now - users only see items they have access to, so they will not be able to send invalid request.

But in general we should probably discuss the way 403 errors are handled by frontend. For now UI will remove the access token and ask user to login.

@YuriiMotov YuriiMotov changed the title 🐛Update items.py "not enough permission" from error code 400 to error code 403 🐛Update items.py to return status code 403 in case of insufficient permissions Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants