Skip to content

fix(training-agent): log why durable GCS reporting failed to start - #9117

Merged
bokelley merged 1 commit into
mainfrom
fix/log-gcs-reporting-init-cause
Nov 20, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/log-gcs-reporting-init-cause

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

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:

{"level":60,...,"err":{"message":"Durable GCS reporting initialization failed; check authority, migrations, credentials and bucket policy.",
 "stack":"... at initializeTrainingGcsReporting (dist/training-agent/gcs-reporting.js:438:15) ..."}}
Main child exited normally with code: 1

The catch around TrainingGcsReporting.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.

  • Startup runs before any account data is read. Credential shapes are still redacted: PEM private keys, Bearer/Basic and ya29. tokens, JWTs, URL userinfo, and private_key / client_secret / *_token / password fields.
  • The raw error never goes to the logger, because pino's err serializer would emit the unredacted message inside stack.
  • Own properties are read by descriptor. A cyclic or hostile error cannot make logging throw.

Tests

training-gcs-reporting-startup: 14/14, with two new cases.

  • One logs nested causes, including a GCS ApiError with code 403, and asserts that no private key, client secret, access token or URL password survives.
  • The other covers cyclic, primitive and hostile errors.

The four other GCS reporting suites pass (58/58), the type check is clean, and the pre-commit hook passes.

🤖 Generated with Claude Code

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>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bokelley
bokelley merged commit 752a5ae into main Nov 20, 2026
56 checks passed
@bokelley
bokelley deleted the fix/log-gcs-reporting-init-cause branch November 20, 2026 01: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.

1 participant