Skip to content

fix(server): re-throw StorageCapacityExhaustedError in POST /identities route catch block - #73

Merged
kjgbot merged 1 commit into
mainfrom
fix/server-503-storage-capacity-route
Aug 3, 2026
Merged

fix(server): re-throw StorageCapacityExhaustedError in POST /identities route catch block#73
kjgbot merged 1 commit into
mainfrom
fix/server-503-storage-capacity-route

Conversation

@kjgbot

@kjgbot kjgbot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The POST /identities route catch block was swallowing StorageCapacityExhaustedError — returning 500 instead of 503
  • app.onError correctly maps it to 503 via storageCapacityResponse, but never saw it because the route's own catch block handled it first
  • Fix: add isStorageCapacityExhausted(error) check before isStorageOverloadedError and re-throw for app.onError to handle
  • Bumps @relayauth/server to 0.2.24
  • Adds HTTP-layer integration test in create-identity.test.ts asserting 503 + storage_capacity_exhausted envelope

Why this matters

Cloud's PostAuthMintCapacityDO gate throws StorageCapacityExhaustedError from storage.identities.create() when the mint window is exhausted. Without this fix, the 503 envelope never reaches the caller — they see a generic 500 identity_create_failed instead of a retryable capacity error.

Cloud PR #2901 (durable post-auth global mint-capacity admission gate) depends on this upstream fix.

Test plan

  • POST /v1/identities returns 503 with capacity envelope when storage.identities.create throws StorageCapacityExhaustedError (new test)
  • Existing create-identity.test.ts suite passes

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kjgbot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 035a0977-1dca-416e-b50a-1205b77adca4

📥 Commits

Reviewing files that changed from the base of the PR and between a14eb35 and 75bd2a9.

📒 Files selected for processing (3)
  • packages/server/package.json
  • packages/server/src/__tests__/create-identity.test.ts
  • packages/server/src/routes/identities.ts
📝 Walkthrough

Walkthrough

The identity creation route now preserves storage capacity exhaustion errors so they produce a retryable 503 response. Regression coverage verifies the error body and response headers. The server package version increases from 0.2.22 to 0.2.24.

Changes

Identity capacity errors

Layer / File(s) Summary
Capacity error propagation and response coverage
packages/server/src/routes/identities.ts, packages/server/src/__tests__/create-identity.test.ts, packages/server/package.json
The route rethrows storage capacity exhaustion errors. Tests verify the 503, storage_capacity_exhausted, retryable status, Retry-After, and Cache-Control: no-store response fields. The package version changes to 0.2.24.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: khaliqgant

Poem

A rabbit found the store was full,
And sent a retry note with care.
The route preserved the proper fault,
With headers floating through the air.
“503,” it thumped, “is clear!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main error-handling fix in the POST /identities route.
Description check ✅ Passed The description directly explains the route fix, its impact, the version update, and the regression test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/server-503-storage-capacity-route
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/server-503-storage-capacity-route

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

…es catch block

The identities route's own catch block was swallowing StorageCapacityExhaustedError
and returning 500 identity_create_failed. app.onError correctly maps it to 503 via
storageCapacityResponse, but it never saw the error because the route caught it first.

Fix: check isStorageCapacityExhausted before the StorageOverloadedError handler and
re-throw so app.onError's capacity mapper handles it correctly.

Bumps @relayauth/server to 0.2.24.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kjgbot
kjgbot force-pushed the fix/server-503-storage-capacity-route branch from a14eb35 to 75bd2a9 Compare August 3, 2026 17:38
@kjgbot
kjgbot merged commit f5369d9 into main Aug 3, 2026
4 checks passed
@kjgbot
kjgbot deleted the fix/server-503-storage-capacity-route branch August 3, 2026 17:54
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.

1 participant