Skip to content

Move Content Sanitizer Lambda RequestId out of the aggregatable error message - #88

Merged
wparad merged 4 commits into
mainfrom
claude/error-log-request-id-fzc1tv
Aug 25, 2026
Merged

Move Content Sanitizer Lambda RequestId out of the aggregatable error message#88
wparad merged 4 commits into
mainfrom
claude/error-log-request-id-fzc1tv

Conversation

@wparad

@wparad wparad commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • AWS sandbox errors (e.g. Sandbox.Timedout) embed a fresh RequestId: <uuid> in errorMessage on every Lambda invocation. LambdaContentSanitizer.extractInvocationErrorDetail() (src/processor/content-sanitizer-client.ts) was folding that text straight into the DbError message, which handler.ts then logs verbatim as the error's title — so every timeout produced a differently-worded log line (e.g. RequestId: 0fdb18b6-f166-4949-b101-e5e2e495fe54 Error: Task timed out after 10.00 seconds), defeating log aggregation by message.
  • The RequestId is still needed for correlation, so instead of dropping it, it's pulled into a new DbError.lambdaRequestId structured field. dbError() (src/errors.ts) now takes an optional { lambdaRequestId } to set it.
  • handler.ts already logs the whole error object (error: result.error) as structured JSON context alongside the message title, so lambdaRequestId still reaches the logs — it just lives in its own field instead of being baked into the message text, so the title stays stable across invocations and errors aggregate correctly (e.g. Content Sanitizer Lambda error: Unhandled — Sandbox.Timedout: Error: Task timed out after 10.00 seconds).

Test plan

  • npx eslint src/
  • npx tsc --noEmit -p tsconfig.check.json
  • npx vitest run tests/processor/content-sanitizer-client.spec.ts — covers the RequestId being moved into lambdaRequestId and stripped from the message, and a pass-through case with no embedded RequestId
  • npm test (lint + typecheck + full vitest suite) — all 2846 tests pass

🤖 Generated with Claude Code

claude added 4 commits August 25, 2026 19:16
invocationId is unique per Lambda invocation, so including it on error
and critical log entries defeated log-aggregation/error-tracking tools
that group errors by identical fields. info/warn/track logs are
unaffected and still carry it for correlation.
invocationId was never embedded in the log message/title text, so
omitting it from error/critical entries wasn't necessary to keep
aggregation working — it's a separate structured field. Revert to
always including it for request correlation.
…ssages

Sandbox.Timedout (and other sandbox) errors embed a fresh "RequestId: <uuid>"
in errorMessage on every invocation. That was flowing straight into the
DbError message text logged by handler.ts, so every timeout produced a
differently-worded log line and defeated aggregation by message.
Instead of dropping the sandbox error's RequestId entirely, pull it into
a new DbError.lambdaRequestId field. It still reaches the logs (handler.ts
already logs the whole error object as structured context), it just no
longer varies the message text used for aggregation.
@wparad wparad changed the title Strip per-invocation RequestId from Content Sanitizer Lambda error messages Move Content Sanitizer Lambda RequestId out of the aggregatable error message Aug 25, 2026
@wparad
wparad merged commit 1e996cd into main Aug 25, 2026
6 checks passed
@wparad
wparad deleted the claude/error-log-request-id-fzc1tv branch August 25, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants