fix: validate token shape before treating post-run config as rotated#31
Conversation
AFTER_TOKEN was compared to BEFORE_TOKEN without checking it's actually a non-empty string first, unlike the "Load PARTNER_CONFIG_JSON" step, which does validate shape. If config.json ends up missing partnerCredentials[partner].token after the run (e.g. a partial/crashed write by the CLI), `jq -r` prints the literal string "null", which differs from BEFORE_TOKEN and reads as "rotated" - triggering an unconditional gh secret set that overwrites the good secret with a broken config. Since this secret has no other writer, that's unrecoverable for the partner until someone manually re-authorizes. Fail closed instead. Found via CodeRabbit review on lu_market#765 and nl_market#893, which had temporarily inlined this job (unrelated experiment); this is the actual upstream source both copies inherited the bug from. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe sampler workflow now validates the post-run partner token before comparing it with the previous value or writing rotated credentials back to the partner secret. ChangesPartner token write-back safety
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8).github/workflows/run_sampler.ymlTraceback (most recent call last): Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Summary
run_sampler.yml's "Capture partner token after the run and write back if rotated" step readsAFTER_TOKENviajq -rand compares it directly toBEFORE_TOKEN, without checking it's actually a non-empty string first — unlike the earlier "Load PARTNER_CONFIG_JSON" step, which does validate shape before proceeding.If
config.jsonends up missingpartnerCredentials[partner].tokenafter the run (e.g. a partial/crashed write by the CLI),jq -rprints the literal string"null", which differs fromBEFORE_TOKENand reads as "rotated" — triggering an unconditionalgh secret setthat overwrites the good secret with a broken config. SincePARTNER_CONFIG_JSON_<partner>has no other writer, that's an unrecoverable regression for that partner until someone manually re-authorizes it.Fix: validate the post-run token's shape the same way the load step already does, and fail closed (refuse to write back) rather than silently corrupting the secret.
How this was found
Flagged by CodeRabbit while nl_market and lu_market temporarily inlined this job into their own wrapper workflows (unrelated experiment - installing silverfin-cli from a branch instead of
mainto gather feedback on a different change). This reusable workflow is the actual upstream source both copies inherited the bug from - already fixed in both:Test plan
ruby -ryaml,actionlint- one pre-existingqueue: maxfalse positive unrelated to this change)🤖 Generated with Claude Code