Skip to content

fix(indexing): return 403 (not 500) when a create-race loser lacks access - #577

Closed
Ahmath-Gadji wants to merge 1 commit into
forward-port/main-to-hexagonalfrom
fix/partition-race-403
Closed

fix(indexing): return 403 (not 500) when a create-race loser lacks access#577
Ahmath-Gadji wants to merge 1 commit into
forward-port/main-to-hexagonalfrom
fix/partition-race-403

Conversation

@Ahmath-Gadji

Copy link
Copy Markdown
Collaborator

What

Follow-up to a review finding on #568 (F11). The partition auto-create race guard (_ensure_editor_access_after_create_race in indexing_service.py) correctly fails closed when a concurrent create lost the race and the loser turns out not to be a member of the partition — but it raised a builtin PermissionError.

Why it matters

The global exception handlers (api/error_handlers.py) map OpenRAGError subclasses to their declared status and everything else to the catch-all 500. So a builtin PermissionError from this guard surfaced a legitimate authorization denial as an Internal Server Error instead of a 403 Forbidden.

This only triggers on the narrow cross-user race (two different users creating the same brand-new partition name simultaneously, where the loser has no membership). It already fails closed — this just corrects the status code. The common case (same user, concurrent uploads — the scenario the race guard was added for) is unaffected: the user owns the partition and the upload continues.

Change

  • indexing_service.py: raise AuthError (status 403) instead of PermissionError.
  • test_indexing_service.py: the cross-user race test now expects AuthError and asserts status_code == 403.

Verification

  • uv run pytest tests/unit/services/orchestrators/test_indexing_service.py → 18 passed
  • ruff check clean

🤖 Generated with Claude Code

…cess

The partition auto-create race guard added for #568 re-verifies editor
membership after a concurrent create lost the race. It raised a builtin
`PermissionError`, which the global exception handlers don't map (only
`OpenRAGError` subclasses get their declared status) — so the catch-all
turned a legitimate authorization denial into an HTTP 500.

Raise `AuthError` (status 403) instead, so a cross-user create race that
the loser isn't a member of returns a clean Forbidden. Same-user
concurrent uploads are unaffected (they own the partition and continue).

Test asserts the raised error carries `status_code == 403`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Ahmath-Gadji, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 28 minutes and 5 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4dd76667-41bf-4b80-882d-f894dea7b63e

📥 Commits

Reviewing files that changed from the base of the PR and between e717a12 and 8fe2779.

📒 Files selected for processing (2)
  • openrag/services/orchestrators/indexing_service.py
  • tests/unit/services/orchestrators/test_indexing_service.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/partition-race-403

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

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

@Ahmath-Gadji

Copy link
Copy Markdown
Collaborator Author

Folded directly into #568 as commit e4314d6 on forward-port/main-to-hexagonal (this PR's base), since it's a follow-up to #568's F11 finding and belongs in that branch. Closing — no separate PR needed.

@Ahmath-Gadji
Ahmath-Gadji deleted the fix/partition-race-403 branch July 17, 2026 08:08
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.

2 participants