Skip to content

fix(auth): return 403 instead of 404 in has_permission decorator#1326

Open
dipak0000812 wants to merge 2 commits intoDalgoT4D:mainfrom
dipak0000812:fix/auth-has-permission-403
Open

fix(auth): return 403 instead of 404 in has_permission decorator#1326
dipak0000812 wants to merge 2 commits intoDalgoT4D:mainfrom
dipak0000812:fix/auth-has-permission-403

Conversation

@dipak0000812
Copy link
Copy Markdown

Summary

Fix incorrect error handling in has_permission decorator.

The current implementation uses a bare except: block that catches HttpError(403) and re-raises it as HttpError(404), causing permission-denied responses to incorrectly return 404 instead of 403.

Changes

  • Removed bare except block
  • Explicitly handle missing or empty request.permissions
  • Ensure permission failures return correct 403 status
  • Allow unexpected errors to propagate

Why

Returning 404 for authorization failures violates HTTP semantics and makes debugging harder. This change ensures accurate status codes and avoids masking real issues.

Impact

  • Correct API behavior for authorization failures
  • Improved debugging clarity
  • Aligns with standard HTTP semantics

Fixes #1325

Remove bare except block that incorrectly converts authorization failures into 404 responses.
Ensure proper 403 response and avoid masking unexpected errors.

Fixes DalgoT4D#1325

Signed-off-by: Dipak <dhangardip09@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Warning

Rate limit exceeded

@dipak0000812 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 21 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d26a8f3c-12ed-479c-808f-c380d077c24a

📥 Commits

Reviewing files that changed from the base of the PR and between 9c957ab and 5e775a4.

📒 Files selected for processing (1)
  • ddpui/auth.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 59 minutes and 21 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Successfully merging this pull request may close these issues.

has_permission decorator returns 404 instead of 403 due to bare except

1 participant