Repository navigation
refactor(errors): Finish the error toast and API error cleanup - #1878
Conversation
showMutationErrorToast and showQuotaExceededToast now live in app/components/error beside toastApiError, and their importers point there. The move clears four modules-not-to-features entries from the dependency-cruiser baseline, since a component may import features.
The server's console calls now go through the shared logger, so they reach the same formatters and Sentry breadcrumbs as the rest of the app. Calls inside request handlers carry the request ID.
scotwells
left a comment
There was a problem hiding this comment.
A caller without a session token now gets 503 from the Grafana connection test instead of 401. The route throws AuthenticationError inside the same try that catches Grafana outages, so its catch reports “Connection failed” before the global handler sees it. Please move the session check outside that try or rethrow the auth error. Cover both cases: a missing token returns 401 without contacting Grafana, and a genuine connection failure keeps the existing 503 body.
🧪 Test Summary
Need another run? Use Re-run failed jobs: one shard costs a few minutes, the whole workflow about 26. |
The api routes now throw the shared error classes, and the global handler answers with the serialized AppError body, filling in the request ID when the error has none. Status codes and messages stay as they were, and the permission client reads the server's message. A 5xx that opts out of Sentry is logged at warn, so none of these reach it.
ae58c26 to
7602d3f
Compare
🧪 Test Summary
Need another run? Use Re-run failed jobs: one shard costs a few minutes, the whole workflow about 26. |
|
@scotwells Good catch, thanks. The session check now runs before the try, so a missing token is a 401 again and never reaches Grafana, and a real connection failure still answers the same 503 body. Both cases have tests now. |
scotwells
left a comment
There was a problem hiding this comment.
Missing credentials now return 401 before the route contacts Grafana. A connection failure still returns 503, so clients can distinguish signing in again from retrying an outage. CI passed.
Problem
showMutationErrorToastlived in the quota module, so 38 files imported their error toasts from quota, and its four imports fromfeatures/only passed the layering rules through the known-violations list. Server code logged throughconsolein 16 places, and/apiroutes answered errors in at least five body shapes, so clients readerror,messageorsuccessdepending on the route.Solution
The toast moves next to
toastApiErrorinapp/components/error/, which clears those four known violations. Server logging goes through@/modules/loggerwith the request ID. The proxy, GraphQL, watch, permissions, usage, user and Grafana routes now throw the existing error classes, and the global handler answers with{ code, message, status, requestId }; status codes and messages are unchanged, and the permission check readsmessage. A 5xx that opts out of Sentry is logged at warn, so Sentry sees the same events as before./api/website,/api/assistant-chat, Grafana's 503 status payload and the health check keep their bodies, because the UI or callers outside this repo read them.Tested locally against staging: a duplicate secret name shows the moved toast with its details, and
/api/usageand/api/permissions/checkreturn the new body with the same request ID as the server log.Preview
Closes #1877