fix(uat): propagate az_federated_relogin step failures - #1725
Conversation
The helper is invoked inside an 'if' condition, which suspends errexit
for the whole function body: a failed OIDC mint, az login, account set,
or token warm-up fell through to the unconditional success echo, whose
0 exit status became the function result — advancing the caller's
re-login timer as if the refresh succeeded and skipping the warning
path, so a later AADSTS700024 would surface without the diagnostic
this mechanism exists to provide. Every step now propagates explicitly
('|| return 1'), the minted token is rejected when empty/null, and the
success message prints only after all steps pass.
Signed-off-by: Mark Chmarny <mark@chmarny.com>
📝 WalkthroughWalkthroughThe Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/uat/azure/run`:
- Around line 149-167: Add regression tests covering token minting errors, empty
or null OIDC tokens, and failures from az login, az account set, and az account
get-access-token. For each case, assert the re-login helper returns non-zero and
the readiness caller preserves last_relogin. Use the existing test setup and
helper/readiness function symbols to mock command failures and verify these
outcomes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: e7be7b96-2134-4851-b5b6-0e96129aa7cc
📒 Files selected for processing (1)
tests/uat/azure/run
yuanchen8911
left a comment
There was a problem hiding this comment.
Verified the fix: each mint/login/warm-up step now propagates failure via || return 1, and the success message prints only after all steps pass, so the caller's warn-and-retry branch actually runs and last_relogin no longer advances on a failed refresh. Reproduced the set -euo pipefail + if az_federated_relogin conditional-context semantics locally to confirm. The empty/null token guard is a good addition. Thanks for the quick turnaround.
Coverage Report ✅
Coverage BadgeNo Go source files changed in this PR. |
Signed-off-by: Mark Chmarny <mark@chmarny.com>
Summary
Follow-up to #1722, addressing @yuanchen8911's review comment:
az_federated_relogincould report success after a failed refresh. Every mint/login/warm-up step now propagates failure explicitly, and the success message prints only after all steps pass.Motivation / Context
The helper is invoked as
if az_federated_relogin; then …, and Bash suspendserrexitinside a function body called in a conditional context. A failed OIDCcurl | jq,az login,az account set, oraz account get-access-tokentherefore fell through to the unconditional successecho, whose 0 exit became the function result — the caller advancedlast_reloginas if the refresh succeeded, skipped the warning/retry path, and a laterAADSTS700024would surface without the diagnostic this mechanism exists to provide.Now each step carries
|| return 1, and the minted token is additionally rejected when empty or the JSON-null string (jq -r .valueon an unexpected response shape).pipefail(set script-wide, unaffected by the conditional context) already propagates acurlfailure through thejqpipe.Fixes: N/A
Related: #1722 (review follow-up)
Type of Change
Component(s) Affected
tests/uat/azure/run)Implementation Notes
Single-function change; the caller's warn-and-retry contract ("the timer only advances on success") is now actually enforced rather than merely documented.
Testing
uat-rundispatch (the gate logs each refresh).Risk Assessment
Checklist
make testwith-race) — no Go changesmake lint)