Repository navigation
fix(host-service): classify missing cloud project in setup as NOT_FOUND - #6433
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesCloud project lookup
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to The change narrowly classifies missing cloud projects as NOT_FOUND while preserving other failures; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Setup as setup
participant Lookup as fetchCloudProjectForSetup
participant Cloud as Cloud API
Setup->>Lookup: Request cloud project
Lookup->>Cloud: Query project
Cloud-->>Lookup: Return project or tRPC error
Lookup-->>Setup: Return project or NOT_FOUND error
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Problem
project.setupfiles a steady trickle ofINTERNAL_SERVER_ERRORreports (HOST-SERVICE-16, 14 events lifetime, 2 in the last 24h, release 1.20.2). The captured stack contains only tRPC client transport frames (TRPCClientError.from), which is why the first-party site was hard to place from the event alone; thetrpc_pathtagproject.setupis what identifies it.Root cause
Setting a project up on a device falls back to a cloud lookup when the project is neither already in the local host database nor accompanied by caller-supplied
origincoordinates:When the cloud has no such project — the ordinary outcome for a project deleted cloud-side, or for an older client trying to adopt one it cannot see — upstream
v2Project.getrejectsNOT_FOUND("Project not found") viarequireOrgScopedResource. Nothing at this boundary caught it, so the rejection propagated out of the mutation and the Sentry middleware, which reports everyINTERNAL_SERVER_ERRORreaching it, filed it as a bug. This is an expected domain state, not a bug, so the missing classification belongs at the throw site.Fix
Wrap that one upstream call in
fetchCloudProjectForSetup. An upstream not-found is rethrown as a typedTRPCErrorwith codeNOT_FOUNDand cause{ kind: "CLOUD_PROJECT_NOT_FOUND" }, so the Sentry middleware never sees a 500. Everything else — network failures, cloud 5xx, auth errors — propagates untouched and keeps reporting.Detection is a
namecheck (error.name === "TRPCClientError"), notinstanceof: errors arriving from the upstream client cross a bundle boundary and lose their prototype. The not-found condition matches the structureddata.code, falling back to a message check only when no structured code is present. The upstream message text is preserved verbatim, so user-facing copy is unchanged. Behaviour is otherwise identical — this is a classification change only.No Sentry-side suppression, no
beforeSendfilter, no middleware allowlist.Verification
bunx biome check packages/host-service/src/trpc/router/project/project.ts:cd packages/host-service && bun run typecheck:bun test src/trpc/router/project/project-import.test.ts(existing tests over the touched router):Refs HOST-SERVICE-16
https://claude.ai/code/session_70334aac-77cb-4a5f-86c0-8cd388bf20a0
Summary by cubic
Classifies a missing cloud project during setup as NOT_FOUND instead of INTERNAL_SERVER_ERROR, reducing Sentry noise and returning a typed not-found to clients. Old behavior: unhandled upstream NOT_FOUND bubbled as 500. New behavior:
TRPCErrorwith codeNOT_FOUNDand cause{ kind: "CLOUD_PROJECT_NOT_FOUND" }. No user-facing copy change.fetchCloudProjectForSetupinpackages/host-service, rethrowing a typed NOT_FOUND.error.name === "TRPCClientError"anddata.code === "NOT_FOUND", with a message fallback; preserve upstream message.originis provided. Network/auth/5xx still propagate and report.Written for commit 1b6e978. Summary will update on new commits.
Summary by CodeRabbit