Dashboard chat endpoints return raw internal errors to the browser #1908

Closed
opened 2026-11-12 12:27:08 +00:00 by sam · 2 comments
Owner

The dashboard chat handlers write raw Go and gRPC error strings straight to the browser: http.Error(w, err.Error(), ...) on the chat endpoints and the SSE error frame written when opening the stream fails. The gateway now maps provider failures to plain wording; these endpoints should do the same, plain message to the browser, cause in the server log.

The dashboard chat handlers write raw Go and gRPC error strings straight to the browser: http.Error(w, err.Error(), ...) on the chat endpoints and the SSE error frame written when opening the stream fails. The gateway now maps provider failures to plain wording; these endpoints should do the same, plain message to the browser, cause in the server log.
sam self-assigned this 2026-11-12 12:33:21 +00:00
Author
Owner

Sanitised dashboard chat error responses.

Changed files:

  • internal/webui/chat.go: every http.Error that could carry internals (the chat 500s, update Check/Install 502s, Defer 409) now goes through a small failChat helper, which logs the real cause with the injected logger's ErrorContext and answers with the plain sentence "something went wrong on Archie's side. Try again; the server log has the cause." (same wording pattern as the gateway's turn failure mapping, duplicated locally because webui must not import the gateway package). The SSE stream-open failure frame sends that plain text too. Safe messages kept as-is: the 400 validation strings, the 404, the static 501s. The update-check writer used by the version endpoint (not a chat endpoint) is untouched.
  • internal/webui/chat_errors_test.go (new): table-driven tests with a contract fake whose error embeds internal details (a SQL fragment, a gRPC status, a server path). They assert the response body and the SSE error frame contain none of those details, do contain the plain sentence, and that the real error reaches the server log. Also locks the kept 400 messages and the 501. Verified the tests fail against the old handlers.

Commands run and results:

  • go test -short ./internal/webui/... -> ok
  • golangci-lint run ./internal/webui/... -> 0 issues
  • task check from the worktree root on the exact committed tree -> exit 0 (fmt, proto:check, db:check, vet, lint, build, go test ./..., pnpm test, vue-tsc typecheck)

PR: #1909

Sanitised dashboard chat error responses. Changed files: - internal/webui/chat.go: every http.Error that could carry internals (the chat 500s, update Check/Install 502s, Defer 409) now goes through a small failChat helper, which logs the real cause with the injected logger's ErrorContext and answers with the plain sentence "something went wrong on Archie's side. Try again; the server log has the cause." (same wording pattern as the gateway's turn failure mapping, duplicated locally because webui must not import the gateway package). The SSE stream-open failure frame sends that plain text too. Safe messages kept as-is: the 400 validation strings, the 404, the static 501s. The update-check writer used by the version endpoint (not a chat endpoint) is untouched. - internal/webui/chat_errors_test.go (new): table-driven tests with a contract fake whose error embeds internal details (a SQL fragment, a gRPC status, a server path). They assert the response body and the SSE error frame contain none of those details, do contain the plain sentence, and that the real error reaches the server log. Also locks the kept 400 messages and the 501. Verified the tests fail against the old handlers. Commands run and results: - go test -short ./internal/webui/... -> ok - golangci-lint run ./internal/webui/... -> 0 issues - task check from the worktree root on the exact committed tree -> exit 0 (fmt, proto:check, db:check, vet, lint, build, go test ./..., pnpm test, vue-tsc typecheck) PR: https://git.catlow.cloud/sam/archie/pulls/1909
Author
Owner

Closed upon merge of #1909

Closed upon merge of #1909
sam closed this issue 2026-11-12 13:33:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1908