Repository navigation
fix(auth): atmos.Component() nested lookups could lose/reuse wrong identity - #2712
Conversation
…rong identity Two defects in the v1.222.0 per-component/nested auth-caching work (#2652/#2656) could surface as "no valid credential sources found / no EC2 IMDS role found" under GitHub OIDC auth with no ambient AWS credentials: - authContextWrapper.GetChain() always returns an empty slice, which the nested-auth cache used to disambiguate parents. Two different real identities reaching a nested lookup via atmos.Component() or !terraform.state/!terraform.output could collide on the same cache key and silently reuse the wrong identity's AuthManager. Wrapper- rooted parents are now never cached. - atmos.Component() always fetched a target's terraform output using the enclosing component's credentials verbatim, unlike !terraform.state/!terraform.output, even when the target declared its own default-identity auth section. It now resolves the target's own auth via resolveAuthManagerForNestedComponent, falling back to the enclosing component's context as before. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change prevents wrapper-based nested auth cache reuse, resolves target-specific auth for nested ChangesNested authentication behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…dentity The !terraform.output YAML function fetched a nested component's outputs using the enclosing component's authContext/authManager verbatim — the same defect just fixed for atmos.Component(). Only !terraform.state actually routed through resolveAuthManagerForNestedComponent; the target-aware resolution was lost when output fetching moved into pkg/terraform/output (which cannot call back into internal/exec). - defaultOutputGetter.GetOutput now resolves the target's own auth section via resolveNestedOutputAuth (target default identity wins; enclosing auth kept when the target has none, on resolver error, or when auth is disabled), mirroring GetTerraformState. - The YAML entry propagates AuthDisabled via authContextWrapper when no AuthManager exists, mirroring !terraform.state, so disabled-auth contexts never trigger target authentication. - Corrected the fix doc's false parity claim and recorded two audited same-class follow-ups (identity-less result-cache keys; store default-identity injection asymmetry). Tests: TestResolveNestedOutputAuth (8 sub-tests, written failing-first). Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/fixes/2026-07-09-atmos-component-nested-auth-cache-collision.md (1)
74-125: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSplit the follow-up material out of this fix note.
The open question and deferred audit items are useful, but they read like separate investigations rather than part of this regression write-up. Moving them to a separate issue or appendix would keep this doc focused and reduce staleness.
🤖 Prompt for 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. In `@docs/fixes/2026-07-09-atmos-component-nested-auth-cache-collision.md` around lines 74 - 125, Move the open question and deferred audit items out of this fix note so the document stays focused on the resolved regression. Keep only the specific nested-auth cache collision fix summary in this file, and relocate the broader follow-up material into a separate issue, appendix, or follow-up doc; adjust the surrounding prose in the markdown note so it no longer reads like an ongoing investigation.
🤖 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 `@internal/exec/terraform_output_getter_test.go`:
- Around line 14-24: Replace the hand-written fakeNestedOutputAuthManager stub
with the generated pkg/auth/types.NewMockAuthManager mock in the
terraform_output_getter_test setup. Configure the mock’s GetStackInfo behavior
to return the desired schema.ConfigAndStacksInfo instead of relying on the
embedded nil auth.AuthManager interface, and update the test code to use the
mock consistently with the existing mockgen pattern.
---
Nitpick comments:
In `@docs/fixes/2026-07-09-atmos-component-nested-auth-cache-collision.md`:
- Around line 74-125: Move the open question and deferred audit items out of
this fix note so the document stays focused on the resolved regression. Keep
only the specific nested-auth cache collision fix summary in this file, and
relocate the broader follow-up material into a separate issue, appendix, or
follow-up doc; adjust the surrounding prose in the markdown note so it no longer
reads like an ongoing investigation.
🪄 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: CHILL
Plan: Pro
Run ID: 766b0ae5-d884-419f-b0a8-45fc649b3ccb
📒 Files selected for processing (5)
docs/fixes/2026-07-09-atmos-component-nested-auth-cache-collision.mdinternal/exec/template_funcs_component.gointernal/exec/terraform_output_getter.gointernal/exec/terraform_output_getter_test.gointernal/exec/yaml_func_terraform_output.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/exec/template_funcs_component.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2712 +/- ##
=======================================
Coverage 81.18% 81.18%
=======================================
Files 1633 1633
Lines 154360 154413 +53
=======================================
+ Hits 125311 125365 +54
+ Misses 22123 22121 -2
- Partials 6926 6927 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…per propagation Address PR #2712 review feedback and patch coverage: - Replace the hand-written fakeNestedOutputAuthManager stub with the mockgen-generated types.NewMockAuthManager, per the repo's mock-generation convention (CodeRabbit review). - Add TestAuthDisabledPropagatesWrapperToOutputGetter covering both branches of the new AuthDisabled wrapper propagation in processTagTerraformOutputWithContext — the uncovered lines behind the 60% patch coverage on yaml_func_terraform_output.go. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.223.0-rc.8. |
what
internal/exec/terraform_nested_auth_helper.goso the nested-auth cache (nestedAuthManagerCache, added in fix(stacks): scope and cache per-component auth in describe stacks #2652/perf(stacks): dedupe per-identity auth in nested terraform.state resolution #2656) never caches a result resolved throughauthContextWrapper— itsGetChain()always returns an empty slice by design, so two different real identities propagated this way could otherwise collide on the same cache key and silently reuse the wrong identity'sAuthManager.internal/exec/template_funcs_component.go(atmos.Component()) so it resolves a nested target's ownauth:section (viaresolveAuthManagerForNestedComponent) instead of always reusing the enclosing component's credentials verbatim — bringing it in line with how!terraform.state/!terraform.outputalready behave.TestBuildComponentAuthCacheKey_AuthContextWrapperNeverCaches,TestResolveComponentFuncAuthManager) and adocs/fixeswrite-up.why
atmos list instancesregressing from v1.221.0 to v1.222.0 under GitHub Actions/OIDC auth (no ambient AWS credentials): a Go template callingatmos.Component(...)to fetch a nested component's terraform output failed withno valid credential sources found ... no EC2 IMDS role found— meaning the subprocess got zero AWS credential material and fell through to the (nonexistent, off-EC2) instance-metadata provider.docs/fixes/2026-06-27-store-hook-inherit-default-identity.md).auth:override of its own) isn't fully explained by these two fixes alone; that residual uncertainty and a debug-log diagnostic for further narrowing are documented indocs/fixes/2026-07-09-atmos-component-nested-auth-cache-collision.md.references