Surface demo budget errors for document loads
From the PR description
Summary
- preserve demo budget errors through Case Vault storage download/signing helpers instead of converting them to null
- return 402
demo_budget_exceededfrom document display, docx, url, and download-token routes - stream DOCX preview bytes through Mike backend instead of redirecting to a Case presigned URL
- show a clear demo-budget message in PDF/DOCX viewers instead of generic failed-to-load/HTTP errors
Production evidence
Recent production logs showed document preview requests failing as 404 while the underlying storage error was DemoBudgetExceededError: Demo budget exhausted for this user. The generated DOCX row exists and is ready in Postgres, so the issue was error masking during Case Vault budget enforcement, not missing document persistence.
Validation
- git diff --check
- npm run build --prefix backend
- cd frontend && npx tsc --noEmit
- npm run build --prefix frontend
Note
There is an unrelated local unstaged edit in frontend/src/app/hooks/useAssistantChat.ts; it is not included in this PR.
Our analysis
Surface demo budget errors through document previews — read the full analysis →
Think the analysis missed something the PR description covers?
Commits in this PR (3)
| SHA | Subject | Author | Date | |
|---|---|---|---|---|
5e899345 | Surface demo budget errors for document loads | kveton | 2026-05-04 | ↗ GitHub |
c4a955e2 | Tune demo usage metering | kveton | 2026-05-04 | ↗ GitHub |
57ba208c | Harden document load error responses | kveton | 2026-05-04 | ↗ GitHub |
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-7.md from
inside the repo you want the changes in.