Skip to content

Strip underscore-prefixed keys from logging redaction - #641

Merged
anth-volk merged 1 commit into
mainfrom
fix/segmented-national-underscore-attrs
Jul 21, 2026
Merged

Strip underscore-prefixed keys from logging redaction#641
anth-volk merged 1 commit into
mainfrom
fix/segmented-national-underscore-attrs

Conversation

@anth-volk

Copy link
Copy Markdown
Contributor

Fixes #640

What

redact_params_for_logging now drops all underscore-prefixed keys, not just the hardcoded _telemetry/_metadata. Correlation ids are still surfaced explicitly.

Why

Merging #637 turned segmented national on, and the deploy failed at beta integration: every segmented-national child (run_simulation_segment) crashed before running any simulation, in its observability wrapper —

File "/root/app.py", line 324, in run_simulation_segment
ValueError: Attribute keys cannot start with an underscore.

Child payloads carry _emit_microdata: True (required — it drives the child's microdata emission for the reduce). run_simulation_segment splats redact_params_for_logging(params) into operation(..., **redacted_params); _emit_microdata survived redaction and reached the observability backend as an attribute key, which the backend rejects. The parent (run_simulation) never carries _emit_microdata, so only the children crashed — the fan-out mechanics and fail-fast otherwise worked. Prod was gated (skipped) and is unaffected; main's deploy pipeline is red until this lands.

#637's staging validation (C7) missed it because the throwaway benchmark's run_simulation_segment called run_simulation_impl directly with no observability wrapper — the exact wrapper that fails.

Fix scope

One rule in logging_redaction.py (not key.startswith("_")) covers all three splat sites (run_simulation, run_simulation_segment, run_budget_window_batch), and future-proofs any new internal _-key. redacted_params feeds only observability attributes — nothing functional depends on it; the real params reach run_simulation_impl untouched.

Tests

  • test_app_redaction.py: new regression asserting no _-prefixed key survives redaction while routing context + run_id are preserved (4 pass).
  • Full confirmation of the child path is the deploy pipeline's national integ test, fail-closed before prod. After this, the child runs the exact code path C7 validated end-to-end (microdata emit + reduce, bit-exact).

🤖 Generated with Claude Code

Segmented-national children carry _emit_microdata, and the observability
wrapper splats redact_params_for_logging(params) into operation() as
attribute keys. The backend rejects keys starting with '_', so every
child crashed before running (Fixes #640 — the post-#637 deploy
failure). redact_params_for_logging now drops all underscore-prefixed
keys (internal control/routing flags, never loggable), not just the
hardcoded _telemetry/_metadata; correlation ids are still surfaced
explicitly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review July 21, 2026 21:54
@anth-volk
anth-volk merged commit 436c36f into main Jul 21, 2026
8 checks passed
@anth-volk
anth-volk deleted the fix/segmented-national-underscore-attrs branch July 21, 2026 21:55
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.

Segmented-national children crash in the observability wrapper (_emit_microdata attribute key)

1 participant