fix(workspace-server): surface secret-safe error_detail on ACTIVITY_LOGGED (internal#212) #1549
Reference in New Issue
Block a user
Delete Branch "fix/wsserver-broadcast-error-detail"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
error_detailon theACTIVITY_LOGGEDWebSocket broadcast so the canvas chat-tab error banner can show why (provider status + error code + human message) instead of the hardcoded opaque "Agent error (Exception) — see workspace logs for details." stringsanitizeErrorDetailForBroadcastredacts bearer tokens /sk-API keys / JWT-shaped strings at the broadcast trust boundary while preserving the actionable parts (HTTP status, error code, human-readable provider message) — over-redacting would defeat the whole point of internal#212Test plan
go test ./internal/handlers/...—TestLogActivity_Broadcast_IncludesErrorDetail,TestLogActivity_Broadcast_OmitsErrorDetailWhenNil,TestSanitizeErrorDetail_StripsSecretShapes/{4 sub-cases},TestLogActivity_Broadcast_ErrorDetailIsSanitizedpassReason field shape
On the wire, the
ACTIVITY_LOGGEDevent payload now carries:Key is omitted when nil/empty so the canvas can gracefully degrade against an older ws-server.
Refs: internal#212, feedback_surface_actionable_failure_reason_to_user
5-axis review: correctness OK (secret-safe scrubber preserves actionable text, JWT shape covered, length cap honored); readability strong (comments map each regex to a class); arch OK (re-scrub at broadcast layer is defense-in-depth on top of runtime _sanitize_for_external); security OK (sk-proj-/Bearer/JWT shapes covered, prefix preserved, body capped 4096); perf OK (regex compiled at package init, single replace per call). Tests pin the actionable-substring contract AND the redaction-must-happen contract. APPROVED.
Reviewed for QA discipline: tests pin both positive (actionable substrings survive) and negative (secret shapes redacted) assertions; nil-error_detail omission test matches request_body/response_body precedent. Real broadcast-layer assertion via recordingBroadcaster, no mocks. APPROVED.