Repository navigation
fix(training-agent): log why durable GCS reporting failed to start - #9117
Conversation
Since 2026-11-17 every production deploy's green machines exit 1 about 30 s after boot with "Durable GCS reporting initialization failed; check authority, migrations, credentials and bucket policy." (deploy run 44546569698's green-machine capture). The catch discarded the underlying error, so the logs cannot say which of those failed. Log the failure's name, message, code, first stack frames and up to four causes before the existing generic throw. Startup runs before any account data is read; credential shapes (private keys, bearer and OAuth access tokens, JWTs, URL userinfo, key/secret/token fields) are redacted anyway, and the raw error never reaches the logger, whose serializer would emit the unredacted message inside the stack. Own properties are read by descriptor, and a hostile or cyclic error cannot make logging throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — operational server change, no blocking or medium findings.
This PR adds cause-logging before the existing generic throw in GCS reporting startup (server/src/training-agent/gcs-reporting.ts, +90/-1) plus a new unit test. No protocol surface touched: no changes under static/schemas/source/, docs/reference/, dist/**, or db migrations, so schema↔docs coherence, changeset scope, oneOf discriminator, artifact immutability, and 3.1.x patch-eligibility gates do not apply. No changeset required for an operational-only change.
Reviewer verified the redaction denylist (PEM/Bearer/ya29./JWT/URL-userinfo/labeled-secret) with correct ordering, stack handling that keeps only at frames, and cycle-safe, depth-bounded, double-try/catch-wrapped recursion so logging cannot throw. Control flow logs before db.end() and rethrow; happy path unchanged. Two new tests cover nested causes/secret absence and cyclic/primitive/hostile inputs.
No no-auto-approve team match. gated_paths is false (review_decision REVIEW_REQUIRED does not trigger row 2 since the gate is path-based and inactive here). high_risk is false. No findings at any tier. Rows 1–8 do not fire; falls through to row 9.
Why
From 17 to 19 November every production deploy failed in the bluegreen rollout. The green-machine capture from #9088 (deploy run 44546569698) showed every new machine exiting with code 1 about 30 s after boot:
The
catcharoundTrainingGcsReporting.create()discards the underlying error, so the logs couldn't say which of those four checks failed. Deploys resumed on 19 Nov (run 44599760968) after a fix on the GCP side. This PR makes the next such failure name its cause.What
Before the existing generic throw, log
failure: the error's name, message, code, first six stack frames, and up to four nested causes.ya29.tokens, JWTs, URL userinfo, andprivate_key/client_secret/*_token/passwordfields.errserializer would emit the unredacted message insidestack.Tests
training-gcs-reporting-startup: 14/14, with two new cases.ApiErrorwith code 403, and asserts that no private key, client secret, access token or URL password survives.The four other GCS reporting suites pass (58/58), the type check is clean, and the pre-commit hook passes.
🤖 Generated with Claude Code