OUT-3674 | Error: Something went wrong in getCustomFieldAccess#58
Conversation
The API route now propagates SDK/DB errors via handleError instead of bubbling an opaque 500, and the page-level helper includes the status code and response body snippet in its thrown error. Improves Sentry diagnostics for PROFILE-MANAGER-35 so we can distinguish bad-token failures from other upstream causes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis is a targeted diagnostic change to improve error observability for a recurring Sentry issue (
Confidence Score: 5/5Safe to merge — the change only adds error handling that was already missing; the happy path is entirely unchanged. The route change wraps existing logic in a try/catch and hands off to handleError, which is already used by other routes. The page-level error messages include the response status and a truncated body from the internal API's own JSON error response, which does not contain credentials. No logic paths were altered, only error surfacing improved. No files require special attention. All three files make narrow, consistent changes. Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant PageServer as Next.js Server (page / manage/page)
participant Route as /api/custom-field-access
participant Copilot as Copilot SDK
participant DB as Prisma
Browser->>PageServer: GET page request
PageServer->>Route: fetch /api/custom-field-access
Route->>Copilot: getCustomFields()
alt Error (e.g. auth failure)
Copilot-->>Route: throws CopilotApiError
Route->>Route: "catch(error) -> handleError(error)"
Route-->>PageServer: JSON error response with status code
PageServer->>PageServer: "res.ok == false"
PageServer->>PageServer: read body.slice(0,200)
PageServer-->>PageServer: throw Error with status + body snippet
Note over PageServer: Sentry captures full error context
else Success
Copilot-->>Route: customFields array
Route->>DB: findAll(portalId)
DB-->>Route: customFieldAccesses
Route-->>PageServer: JSON data response
PageServer-->>Browser: Rendered page
end
Reviews (1): Last reviewed commit: "fix(OUT-3674): surface real cause of get..." | Re-trigger Greptile |
Summary
/api/custom-field-accessGET in try/catch +handleErrorso Copilot SDK / Prisma errors surface their real status and message instead of an opaque Next.js 500 (matches the existing pattern inprofile-update-history/route.ts).getCustomFieldAccesson bothapp/page.tsxandapp/manage/page.tsx, include the response status and a 200-char body snippet in the thrown error.This is a diagnostic-only change. Sentry issue PROFILE-MANAGER-35 (24 events) currently throws a generic
Something went wrong in getCustomFieldAccesswith no upstream context — we don't know whether the API route is failing on SDK auth, the Copilot platform API, Prisma, or schema validation. After this lands, the next batch of events will show the real cause (e.g.getCustomFieldAccess failed: 401 {"message":"Unable to authorize Copilot SDK."}), letting us decide whether PM-35 is the same non-actionable token-rejection population as PROFILE-MANAGER-34 or something we can actually fix.Resolves OUT-3674 once we have enough new events to triage.
Test plan
/and/managewith a valid token — both pages render normally (happy path unchanged)./api/custom-field-accesswith a malformed token — confirm route returns a JSON error body (not an unhandled 500).🤖 Generated with Claude Code