Skip to content

fix(auth): honor --identity=false in describe affected and dependents#2471

Merged
Andriy Knysh (aknysh) merged 4 commits into
mainfrom
osterman/auth-error-1219-regression
May 22, 2026
Merged

fix(auth): honor --identity=false in describe affected and dependents#2471
Andriy Knysh (aknysh) merged 4 commits into
mainfrom
osterman/auth-error-1219-regression

Conversation

@osterman
Copy link
Copy Markdown
Member

@osterman Erik Osterman (Cloud Posse) (osterman) commented May 21, 2026

what

  • Honor --identity=false (and aliases off/0/no) in atmos describe affected so per-component auth resolution is skipped, not just the top-level AuthManager creation.
  • Thread a new DescribeAffectedCmdArgs.AuthDisabled / DescribeDependentsArgs.AuthDisabled flag from the cmd layer through executeDescribeAffectedWith{TargetRepoPath,TargetRefClone,TargetRefCheckout}, executeDescribeAffected, addDependentsToAffected, and ExecuteDescribeDependents, routing inner stack resolution through ExecuteDescribeStacksWithAuthDisabled.
  • Also wired through terraform_affected.go, terraform_affected_graph.go, pkg/list/list_affected.go, pkg/ai/tools/atmos/describe_affected.go, and atlantis_generate_repo_config.go so every caller of the public helpers passes the signal.
  • Extracted pkg/list/list_affected.go::executeAffectedLogic into three per-mode helpers to stay under the 60-line function-length limit after the extra parameter.

why

  • A user disabled all auth on a describe affected --upload --process-functions=false --identity=false run in cloudposse/infra-live CI (failing run) and still got STS AssumeRoleWithWebIdentity 403 AccessDenied for component tfstate-plat.
  • The 1.219 fix (fix(auth): normalize --identity=false to disable authentication #2412) normalized --identity=false__DISABLED__ at the parser layer and made CreateAuthManagerFromIdentity* short-circuit to nil, but it only wired the disabled signal all the way down through list instances. In describe affected, the top-level AuthManager correctly became nil, but a nil AuthManager was indistinguishable from "no identity specified" downstream. With --process-templates=true (the default), shouldResolvePerComponentAuth(processTemplates, processYamlFunctions) still returned true, so the per-component resolver called createComponentAuthManager, which built a fresh AuthManager from atmosConfig.Auth and tried the assume-role call the user thought they had disabled.
  • This change makes --identity=false actually mean "no auth, anywhere" in describe affected, matching the contract that already works for list instances.

Tests:

  • cmd/describe_affected_test.go::TestDescribeAffectedSetsAuthDisabled covers false/off/0/no env-var spellings and asserts AuthDisabled=true and AuthManager=nil.
  • internal/exec/describe_affected_authdisabled_test.go verifies Execute() forwards AuthDisabled to all three helper paths and to addDependentsToAffected.
  • internal/exec/describe_stacks_component_processor_auth_test.go adds the exact (processTemplates=true, processYamlFunctions=false, authDisabled=true) regression case from the infra-live CI failure to the existing table.

references

Summary by CodeRabbit

  • Bug Fixes

    • describe affected and describe dependents now explicitly record when authentication is disabled (e.g., --identity=false, off, 0, no), ensuring downstream discovery and dependency resolution skip per-component auth and avoid unintended auth attempts.
  • Tests

    • Added unit and integration tests verifying the auth-disabled signal is propagated throughout affected-component discovery and dependent-resolution paths.

Review Change Stack

`--identity=false` (and aliases `off`/`0`/`no`) normalized correctly at the
parser layer in 1.219 (PR #2412), but the disabled signal was only wired
through `list instances`. In `describe affected`, the top-level AuthManager
correctly became nil, but a nil AuthManager was indistinguishable from "no
identity specified" downstream — so the per-component auth resolver still
ran whenever `processTemplates` was true (its default), reintroducing the
AssumeRoleWithWebIdentity call the user tried to disable.

Thread an `AuthDisabled bool` from the cmd layer through
`executeDescribeAffectedWith*`, `executeDescribeAffected`,
`addDependentsToAffected`, and `ExecuteDescribeDependents`, routing inner
stack resolution through `ExecuteDescribeStacksWithAuthDisabled` so
`processor.authDisabled=true` short-circuits the per-component resolver.

Also propagated through `terraform_affected.go`,
`terraform_affected_graph.go`, `pkg/list/list_affected.go`,
`pkg/ai/tools/atmos/describe_affected.go`, and
`atlantis_generate_repo_config.go` call sites. Extracted
`pkg/list/list_affected.go::executeAffectedLogic` into three per-mode
helpers to stay under the 60-line function-length limit.

Tests:
- cmd/describe_affected_test.go::TestDescribeAffectedSetsAuthDisabled
  verifies `false`/`off`/`0`/`no` env values set `AuthDisabled=true` and
  `AuthManager=nil`.
- internal/exec/describe_affected_authdisabled_test.go verifies
  `Execute()` forwards `AuthDisabled` to all three helper paths and to
  `addDependentsToAffected`.
- describe_stacks_component_processor_auth_test.go adds the exact
  `(processTemplates=true, processYamlFunctions=false, authDisabled=true)`
  regression case from the infra-live CI failure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@atmos-pro
Copy link
Copy Markdown
Contributor

atmos-pro Bot commented May 21, 2026

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More.

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label May 21, 2026
@github-actions github-actions Bot added the size/m Medium size PR label May 21, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 71a63a01-9fc6-4f90-940f-55a27c64a2ee

📥 Commits

Reviewing files that changed from the base of the PR and between 73a0f93 and c8f0656.

📒 Files selected for processing (4)
  • cmd/describe_dependents.go
  • cmd/describe_dependents_test.go
  • internal/exec/describe_dependents.go
  • internal/exec/describe_dependents_authdisabled_test.go

📝 Walkthrough

Walkthrough

This PR adds an explicit AuthDisabled boolean flag to CLI props/args for describe-affected and describe-dependents, threads it through executor/helper signatures and execution, switches relevant stacks discovery to ExecuteDescribeStacksWithAuthDisabled, and updates callers and tests to forward/verify the flag.

Changes

AuthDisabled flag threading through describe affected

Layer / File(s) Summary
Command-level flag capture
cmd/describe_affected.go, cmd/describe_affected_test.go, cmd/describe_dependents.go, cmd/describe_dependents_test.go
When --identity equals the disabled sentinel, props.AuthDisabled/DescribeAffectedCmdArgs.AuthDisabled is set (distinct from a nil AuthManager); new tests validate false-like inputs normalize to disabled.
Executor args and helper signatures
internal/exec/describe_affected.go, internal/exec/describe_affected_helpers.go, internal/exec/describe_affected_authdisabled_test.go
DescribeAffectedCmdArgs gains AuthDisabled; internal function-pointer fields and exported helper signatures accept authDisabled and forward it; unit tests assert correct routing and helper selection.
Core execute and stacks discovery
internal/exec/describe_affected_utils.go, internal/exec/describe_affected_utils_2.go
executeDescribeAffected and addDependentsToAffected accept authDisabled and call ExecuteDescribeStacksWithAuthDisabled for current and base/remote stack discovery, threading the flag through dependent-index building.
Callers, integrations, and tests
internal/exec/terraform_affected.go, internal/exec/terraform_affected_graph.go, pkg/list/list_affected.go, internal/exec/atlantis_generate_repo_config.go, pkg/ai/tools/atmos/describe_affected.go, plus many test files
Callers derive/compute authDisabled from identity and pass it into ExecuteDescribeAffectedWithTarget*; tests and stubs updated to include the new boolean argument and assertions.
Regression and unit tests for component auth
internal/exec/describe_stacks_component_processor_auth_test.go, internal/exec/describe_dependents_authdisabled_test.go
Added/updated tests assert that per-component auth resolution is skipped when authDisabled is true and that AuthDisabled is forwarded through describe-dependents execution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • cloudposse/atmos#2412: Normalizes --identity=false input to the disabled sentinel value that enables this PR's AuthDisabled propagation.
  • cloudposse/atmos#1935: Related fixes around recognizing disabled identity sentinel values used by this PR.
  • cloudposse/atmos#2250: Threads auth-related arguments through the same describe-affected execution chain where this PR adds AuthDisabled.

Suggested reviewers

  • aknysh
  • milldr
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 59.02% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making --identity=false honored end-to-end in describe affected and dependents commands by threading an AuthDisabled flag through the execution path.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/auth-error-1219-regression

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cmd/describe_affected_test.go (1)

218-251: ⚡ Quick win

Add a direct --identity flag case to this test.

Current cases validate env/viper aliases, but the explicit CLI flag normalization path (--identity=false|off|0|no) is still untested here. Add at least one case that sets the command flag directly and confirms it wins over env/viper inputs.

As per coding guidelines "Support configuration via files, environment variables, and flags following the precedence order: flags > environment variables > config file > defaults".

🤖 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 `@cmd/describe_affected_test.go` around lines 218 - 251, Add a new test case to
cover the explicit CLI flag path so flags take precedence over env/viper: update
the tests slice in cmd/describe_affected_test.go to include a case that sets the
describeAffectedCmd flag "--identity" to a falsey value (e.g., "false" or "off")
when calling run(describeAffectedCmd, []string{"--identity=false"}), then assert
that captured.AuthDisabled on the exec.DescribeAffectedCmdArgs produced by
getRunnableDescribeAffectedCmd (the runnable created around
ParseDescribeAffectedCliArgs and the mock exec) reflects the flag (true for
disabled); this ensures the describeAffectedCmd flag normalization path is
exercised and wins over env/viper inputs.
🤖 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/describe_dependents.go`:
- Line 45: DescribeDependentsArgs.AuthDisabled is never propagated because
DescribeDependentsExecProps lacks an AuthDisabled field, so
describeDependentsExec.Execute always sees the default false; add an
AuthDisabled bool to DescribeDependentsExecProps, set it from
DescribeDependentsArgs.AuthDisabled where the props are constructed, and ensure
describeDependentsExec.Execute reads the new props.AuthDisabled when choosing
the auth-disabled execution path (reference DescribeDependentsArgs.AuthDisabled,
DescribeDependentsExecProps, and describeDependentsExec.Execute).

---

Nitpick comments:
In `@cmd/describe_affected_test.go`:
- Around line 218-251: Add a new test case to cover the explicit CLI flag path
so flags take precedence over env/viper: update the tests slice in
cmd/describe_affected_test.go to include a case that sets the
describeAffectedCmd flag "--identity" to a falsey value (e.g., "false" or "off")
when calling run(describeAffectedCmd, []string{"--identity=false"}), then assert
that captured.AuthDisabled on the exec.DescribeAffectedCmdArgs produced by
getRunnableDescribeAffectedCmd (the runnable created around
ParseDescribeAffectedCliArgs and the mock exec) reflects the flag (true for
disabled); this ensures the describeAffectedCmd flag normalization path is
exercised and wins over env/viper inputs.
🪄 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: 6698dea9-e7d8-4606-9841-2a3aa341c1ed

📥 Commits

Reviewing files that changed from the base of the PR and between b010bae and 433f7b1.

📒 Files selected for processing (19)
  • cmd/describe_affected.go
  • cmd/describe_affected_test.go
  • internal/exec/atlantis_generate_repo_config.go
  • internal/exec/describe_affected.go
  • internal/exec/describe_affected_authdisabled_test.go
  • internal/exec/describe_affected_helpers.go
  • internal/exec/describe_affected_test.go
  • internal/exec/describe_affected_utils.go
  • internal/exec/describe_affected_utils_2.go
  • internal/exec/describe_affected_utils_test.go
  • internal/exec/describe_dependents.go
  • internal/exec/describe_stacks_component_processor_auth_test.go
  • internal/exec/terraform_affected.go
  • internal/exec/terraform_affected_graph.go
  • pkg/ai/tools/atmos/describe_affected.go
  • pkg/describe/describe_affected_test.go
  • pkg/list/list_affected.go
  • tests/describe_affected_greenfield_test.go
  • tests/describe_affected_include_test.go

Comment thread internal/exec/describe_dependents.go
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 33.01887% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.23%. Comparing base (21681f9) to head (0c5fa44).

Files with missing lines Patch % Lines
pkg/list/list_affected.go 0.00% 62 Missing ⚠️
internal/exec/atlantis_generate_repo_config.go 57.14% 3 Missing ⚠️
internal/exec/terraform_affected_graph.go 40.00% 3 Missing ⚠️
internal/exec/describe_affected_utils.go 75.00% 2 Missing ⚠️
internal/exec/describe_affected_helpers.go 66.66% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (33.01%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2471      +/-   ##
==========================================
+ Coverage   78.22%   78.23%   +0.01%     
==========================================
  Files        1119     1119              
  Lines      106205   106243      +38     
==========================================
+ Hits        83074    83124      +50     
+ Misses      18494    18478      -16     
- Partials     4637     4641       +4     
Flag Coverage Δ
unittests 78.23% <33.01%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/describe_affected.go 89.58% <100.00%> (+0.22%) ⬆️
cmd/describe_dependents.go 69.23% <100.00%> (+0.48%) ⬆️
internal/exec/describe_affected.go 79.09% <100.00%> (+0.22%) ⬆️
internal/exec/describe_affected_utils_2.go 78.31% <100.00%> (+0.05%) ⬆️
internal/exec/describe_dependents.go 93.91% <100.00%> (+0.04%) ⬆️
internal/exec/terraform_affected.go 92.30% <100.00%> (+0.30%) ⬆️
pkg/ai/tools/atmos/describe_affected.go 62.82% <100.00%> (+0.48%) ⬆️
internal/exec/describe_affected_helpers.go 41.61% <66.66%> (+0.47%) ⬆️
internal/exec/describe_affected_utils.go 77.51% <75.00%> (-0.07%) ⬇️
internal/exec/atlantis_generate_repo_config.go 60.59% <57.14%> (+0.59%) ⬆️
... and 2 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Address pre-commit hook failures from PR #2471 CI run. The newer gofumpt
in CI flagged formatting in four files I touched in the previous commit:

- pkg/list/list_affected.go — split `})` from inline closure into
  `},` + `)` on separate lines.
- internal/exec/describe_affected_utils.go — split the long log.Warn
  message into its own line in two greenfield-handling branches.
- internal/exec/atlantis_generate_repo_config.go — split trailing args
  in two errors.Errorf calls onto their own lines.
- internal/exec/describe_affected_utils_2.go — remove redundant parens
  from `&((*slice)[i])` → `&(*slice)[i]` in four loop bodies.

No behavior change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address CodeRabbit review on PR #2471. The previous commit added
`AuthDisabled` to `DescribeDependentsArgs` but missed adding it to
`DescribeDependentsExecProps`, which is the type that `describe dependents`
constructs from CLI flags and passes to `describeDependentsExec.Execute`.
The executor then built a `DescribeDependentsArgs` without the flag, so the
inner `ExecuteDescribeStacksWithAuthDisabled` always received
`authDisabled=false` — re-introducing the per-component auth attempt for
`atmos describe dependents --identity=false`.

- internal/exec/describe_dependents.go: add `AuthDisabled` to
  `DescribeDependentsExecProps` and forward it into `DescribeDependentsArgs`
  inside `describeDependentsExec.Execute`.
- cmd/describe_dependents.go: set `describe.AuthDisabled` from the
  normalized identity name, mirroring the wiring in `cmd/describe_affected.go`.

Tests:
- cmd/describe_dependents_test.go::TestDescribeDependentsSetsAuthDisabled —
  table covers `false`/`off`/`0`/`no` env spellings.
- internal/exec/describe_dependents_authdisabled_test.go —
  TestDescribeDependentsExec_Execute_ForwardsAuthDisabled pins the
  executor-side prop → arg propagation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aknysh Andriy Knysh (aknysh) merged commit a0cd286 into main May 22, 2026
58 checks passed
@aknysh Andriy Knysh (aknysh) deleted the osterman/auth-error-1219-regression branch May 22, 2026 05:41
@atmos-pro
Copy link
Copy Markdown
Contributor

atmos-pro Bot commented May 22, 2026

Note

Atmos Pro  

Waiting for your GitHub Actions workflow to upload affected stacks.
Learn More.

@github-actions
Copy link
Copy Markdown

These changes were released in v1.220.0-rc.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants