Repository navigation
feat: dependency-closure selection (--include-dependencies/--include-dependents) + scope --labels/--tags evaluation before filtering - #2807
Conversation
…ltering On a monorepo spanning multiple AWS accounts, atmos terraform ... --all --labels/--tags and atmos list dependencies --stack <stack> fully evaluated (templates, YAML functions, auth) every stack in the repo before consulting the requested selector, failing on an unrelated/inaccessible stack before the command ever got to the user's actual target. Generalizes the existing -s/--stack early-skip (see docs/fixes/2026-06-22-describe-stacks-scope-and-cache-per-component-auth.md) to --labels/--tags, and reworks `list dependencies` to compute a reachable dependency closure and only fully evaluate the stacks that closure touches.
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds tag and label filters, depth-limited dependency closure, scoped evaluation, selector validation, and ChangesScoped selection and dependency closure
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
internal/exec/describe_stacks.go (1)
346-384: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftParameter list keeps growing on
executeDescribeStacks.This internal function is now up to ~17 positional parameters, with several adjacent
bools (authDisabled,useMocks,resolveSecrets) plus the two new filters. A transposition at any call site (e.g. swappingauthDisabled/useMocks) would compile silently and misbehave at runtime.As per coding guidelines,
**/*.go: "Use the functional options pattern for configuration instead of functions with many parameters." Consider introducing an options struct (or functional options) forexecuteDescribeStacksbefore more flags accumulate here.🤖 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 `@internal/exec/describe_stacks.go` around lines 346 - 384, Refactor executeDescribeStacks to accept a dedicated options struct or functional options instead of its growing positional argument list, especially the adjacent authDisabled, useMocks, and resolveSecrets flags and the filters. Update every call site to use named configuration fields/options while preserving all existing behavior and values.Source: Coding guidelines
🤖 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
`@docs/fixes/2026-07-25-scope-before-evaluate-labels-tags-list-dependencies.md`:
- Around line 84-85: The documented eager-evaluation setting path is incorrect.
Replace settings.describe.settings.eager_evaluation with
describe.settings.eager_evaluation in
docs/fixes/2026-07-25-scope-before-evaluate-labels-tags-list-dependencies.md at
lines 84-85 and 146-150, and update the corresponding helper comment in
internal/exec/describe_stacks_component_processor.go lines 724-727 and test
comment in internal/exec/describe_stacks_component_processor_scope_test.go lines
318-322; no behavioral code changes are needed.
In `@pkg/list/dependencies/closure.go`:
- Around line 48-69: Update StackNames to sort the deduplicated names slice
before returning it, preserving the existing nil handling and deduplication
behavior so results are deterministic as documented.
In `@tests/fixtures/scenarios/dependencies-scoped-evaluation/atmos.yaml`:
- Around line 12-17: Update the terraform base_path in the scenario fixture to
point to the local component root under components/terraform when directory
validation is part of the scenario; otherwise preserve the existing path and
document that it intentionally scopes dependency evaluation outside this
fixture.
---
Nitpick comments:
In `@internal/exec/describe_stacks.go`:
- Around line 346-384: Refactor executeDescribeStacks to accept a dedicated
options struct or functional options instead of its growing positional argument
list, especially the adjacent authDisabled, useMocks, and resolveSecrets flags
and the filters. Update every call site to use named configuration
fields/options while preserving all existing behavior and values.
🪄 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 Plus
Run ID: 6ddbfc95-a5fb-43bd-a474-29f69de3540c
📒 Files selected for processing (17)
cmd/list/dependencies.gocmd/list/dependencies_scoped_test.godocs/fixes/2026-07-25-scope-before-evaluate-labels-tags-list-dependencies.mdinternal/exec/describe_stacks.gointernal/exec/describe_stacks_component_processor.gointernal/exec/describe_stacks_component_processor_scope_test.gointernal/exec/filter_utils.gointernal/exec/terraform_all.gointernal/exec/terraform_query.gointernal/exec/terraform_utils_test.gopkg/list/dependencies/closure.gopkg/list/dependencies/closure_test.gopkg/schema/schema.gotests/fixtures/scenarios/dependencies-scoped-evaluation/atmos.yamltests/fixtures/scenarios/dependencies-scoped-evaluation/components/terraform/mock/main.tftests/fixtures/scenarios/dependencies-scoped-evaluation/stacks/deploy/app-a.yamltests/fixtures/scenarios/dependencies-scoped-evaluation/stacks/deploy/app-b.yaml
atmos validate --affected's editorconfig check requires markdown indentation in multiples of 2 (.editorconfig sets indent_size=2 for *.md). The Symptom section's two numbered-list items used 3-space continuation indent, failing CI.
The Acceptance Tests suite (linux/macos/windows) failed TestEmbeddedSchemaIsCurrent: adding describe.settings.eager_evaluation to schema.DescribeSettings in 62a35aa left the embedded JSON schema stale. Regenerated via `go generate ./pkg/config/schema`.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2807 +/- ##
==========================================
+ Coverage 81.95% 82.11% +0.15%
==========================================
Files 1798 1802 +4
Lines 173942 175133 +1191
==========================================
+ Hits 142555 143803 +1248
+ Misses 23624 23566 -58
- Partials 7763 7764 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…cept ':' in --labels `atmos list stacks` had no way to filter by metadata.tags/metadata.labels even though `list components` already did. Extends the same --tags/--labels filtering to list stacks, instances, metadata, sources, and dependencies, and --tags only to list vendor (manifest-declared tags, not stack metadata; no labels concept in that schema). Also accepts ':' as an alternative to '=' in --labels pairs (e.g. --labels=team:platform) everywhere the shared parser is used (terraform --all, container/kubernetes/helm verbs, list components). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/list/sources.go (1)
196-228: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftApply selectors before describe-stack evaluation.
This calls
executeDescribeStacksForSourceswith nil selectors, then filters at line 228. Sources excluded by--tags/--labelsstill run template/YAML-function evaluation and can trigger unnecessary authentication or failures, which defeats this PR’s scoped-evaluation goal. Propagate these selectors into the describe path before evaluation.🤖 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/list/sources.go` around lines 196 - 228, Update fetchAndFilterSources to pass the requested component, tags, and parsed labels into executeDescribeStacksForSources instead of supplying nil selectors. Ensure these selectors are applied during describe-stack evaluation, while retaining the final source filtering for the returned results.
🧹 Nitpick comments (3)
cmd/list/stacks.go (1)
262-286: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winValidate
--labelsbefore, not after, the expensive evaluation pass. Both sites parse the raw--labelsstring only after running the full (potentially template/YAML-function-heavy) evaluation, so bad input pays the full cost before failing — at odds with this PR's own goal of scoping work before evaluation.
cmd/list/stacks.go#L262-L286: move thetags.ParseLabelsFlag(opts.LabelsRaw)call (and its error return) above thee.ExecuteDescribeStacksWithOptions(...)call inexecuteAndExtractStacks.pkg/list/list_instances.go#L802-L836: validateopts.LabelsRawviatags.ParseLabelsFlagbefore callingprocessInstances, instead of only insidebuildInstanceFiltersafter the fact.🤖 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/list/stacks.go` around lines 262 - 286, Validate opts.LabelsRaw before expensive evaluation in executeAndExtractStacks by moving tags.ParseLabelsFlag and its error return ahead of ExecuteDescribeStacksWithOptions. Also update pkg/list/list_instances.go lines 802-836 to parse and validate opts.LabelsRaw before processInstances; reuse the validated labels in buildInstanceFilters rather than deferring validation there.cmd/list/vendor_test.go (2)
106-112: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise actual flag parsing.
The test only checks the command’s local flag set; it does not prove that executing the vendor parser rejects
--labels. Assert the real parsing path returns an unknown-flag error, while retaining the positive--tagsregistration check.As per coding guidelines, tests should verify behavior rather than implementation details.
🤖 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/list/vendor_test.go` around lines 106 - 112, Update TestVendorCmd_LabelsFlagNotRegistered to execute the vendor command’s actual argument-parsing path with --labels and assert it returns an unknown-flag error. Retain the positive assertion that --tags is accepted or registered, but remove the direct vendorCmd.Flags().Lookup("labels") implementation-detail check.Source: Coding guidelines
67-104: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover filter behavior with table-driven cases.
These hand-written subtests do not verify multi-tag “matches any” behavior or the actual intersection of stack and tag filters; the stack-plus-tags case only checks the filter count. Refactor into table-driven cases and include multiple requested tags plus matching/nonmatching stack rows.
As per coding guidelines, Go tests should use table-driven scenarios and verify behavior rather than only construction.
🤖 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/list/vendor_test.go` around lines 67 - 104, The TestBuildVendorFilters_Tags tests should be refactored into table-driven scenarios that exercise behavior rather than only filter construction. Add cases covering no filters, multiple requested tags with “matches any” semantics, tags-only matching and nonmatching rows, and combined stack glob plus tags using rows that both match and fail the intersection; assert the resulting components or row counts for each case.Source: Coding guidelines
🤖 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 `@cmd/list/parse_options_test.go`:
- Around line 256-264: Extend the existing “tags_flag” test or add a nearby case
to set the dependencies command’s “labels” flag to “team:platform” and assert
that parseDependenciesOptions populates opts.LabelsRaw with the expected value,
while preserving the current tags assertion.
In `@cmd/list/sources_test.go`:
- Around line 781-806: The filterSourcesByTagsLabels tests should verify exact
returned entries and distinguish matching semantics. Strengthen “no filters is
passthrough” by asserting all expected sources, add multi-tag coverage for
any-match behavior, and add multi-label coverage requiring all labels to match;
retain assertions that returned components identify the correct rows.
In `@cmd/list/sources.go`:
- Around line 215-218: Update the error branch after tags.ParseLabelsFlag in the
list command to wrap the parsing error with the existing
invalid-flag/list-command static error while retaining err as the cause. Reuse
the repository’s established error-wrapping convention and leave successful
label parsing unchanged.
In `@cmd/list/vendor_test.go`:
- Around line 99-102: Replace the non-fatal assert.True and assert.Len checks
for filtered in the vendor test with require.True and require.Len, ensuring both
preconditions complete before indexing filtered[0]. Keep the existing validation
of the component value unchanged.
In `@pkg/list/list_instances_test.go`:
- Around line 76-101: Extend TestBuildInstanceFilters_FiltersRows in
pkg/list/list_instances_test.go (lines 76-101) with multi-tag and multi-label
rows and selectors that verify tag any-match, label all-match, and their
same-row intersection; retain only rows satisfying both combined filters. Add
equivalent multi-value selector coverage to the metadata row tests in
pkg/list/list_metadata_test.go (lines 353-375), targeting the relevant metadata
filter test and asserting behavior rather than implementation details.
---
Outside diff comments:
In `@cmd/list/sources.go`:
- Around line 196-228: Update fetchAndFilterSources to pass the requested
component, tags, and parsed labels into executeDescribeStacksForSources instead
of supplying nil selectors. Ensure these selectors are applied during
describe-stack evaluation, while retaining the final source filtering for the
returned results.
---
Nitpick comments:
In `@cmd/list/stacks.go`:
- Around line 262-286: Validate opts.LabelsRaw before expensive evaluation in
executeAndExtractStacks by moving tags.ParseLabelsFlag and its error return
ahead of ExecuteDescribeStacksWithOptions. Also update
pkg/list/list_instances.go lines 802-836 to parse and validate opts.LabelsRaw
before processInstances; reuse the validated labels in buildInstanceFilters
rather than deferring validation there.
In `@cmd/list/vendor_test.go`:
- Around line 106-112: Update TestVendorCmd_LabelsFlagNotRegistered to execute
the vendor command’s actual argument-parsing path with --labels and assert it
returns an unknown-flag error. Retain the positive assertion that --tags is
accepted or registered, but remove the direct vendorCmd.Flags().Lookup("labels")
implementation-detail check.
- Around line 67-104: The TestBuildVendorFilters_Tags tests should be refactored
into table-driven scenarios that exercise behavior rather than only filter
construction. Add cases covering no filters, multiple requested tags with
“matches any” semantics, tags-only matching and nonmatching rows, and combined
stack glob plus tags using rows that both match and fail the intersection;
assert the resulting components or row counts for each case.
🪄 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 Plus
Run ID: 20c38a68-c611-42d6-8c82-341031ba7942
📒 Files selected for processing (59)
cmd/container/verbs.gocmd/helm/helm.gocmd/kubernetes/kubernetes.gocmd/list/dependencies.gocmd/list/flag_wrappers.gocmd/list/instances.gocmd/list/instances_test.gocmd/list/metadata.gocmd/list/parse_options_test.gocmd/list/sources.gocmd/list/sources_test.gocmd/list/stacks.gocmd/list/vendor.gocmd/list/vendor_test.gocmd/terraform/flags.gopkg/list/dependencies/closure.gopkg/list/dependencies/closure_test.gopkg/list/dependencies/render.gopkg/list/dependencies/render_test.gopkg/list/extract/components.gopkg/list/extract/metadata.gopkg/list/extract/metadata_test.gopkg/list/extract/stacks.gopkg/list/extract/stacks_test.gopkg/list/extract/vendor.gopkg/list/extract/vendor_test.gopkg/list/list_instances.gopkg/list/list_instances_coverage_test.gopkg/list/list_instances_test.gopkg/list/list_metadata.gopkg/list/list_metadata_test.gopkg/tags/flags.gopkg/tags/flags_test.gowebsite/docs/cli/commands/container/usage.mdxwebsite/docs/cli/commands/helm/helm-apply.mdxwebsite/docs/cli/commands/helm/helm-delete.mdxwebsite/docs/cli/commands/helm/helm-deploy.mdxwebsite/docs/cli/commands/helm/helm-diff.mdxwebsite/docs/cli/commands/helm/helm-plan.mdxwebsite/docs/cli/commands/helm/helm-template.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-apply.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-delete.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-deploy.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-diff.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-plan.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-render.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-validate.mdxwebsite/docs/cli/commands/kubernetes/usage.mdxwebsite/docs/cli/commands/list/list-components.mdxwebsite/docs/cli/commands/list/list-dependencies.mdxwebsite/docs/cli/commands/list/list-instances.mdxwebsite/docs/cli/commands/list/list-metadata.mdxwebsite/docs/cli/commands/list/list-sources.mdxwebsite/docs/cli/commands/list/list-stacks.mdxwebsite/docs/cli/commands/list/list-vendor.mdxwebsite/docs/cli/commands/terraform/terraform-apply.mdxwebsite/docs/cli/commands/terraform/terraform-deploy.mdxwebsite/docs/cli/commands/terraform/terraform-plan.mdxwebsite/docs/cli/commands/terraform/usage.mdx
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/list/dependencies/closure_test.go
- cmd/list/dependencies.go
- pkg/list/dependencies/closure.go: StackNames now actually sorts (doc claimed "sorted" but graph.Nodes iteration is a non-deterministic map). - Correct the eager-evaluation config path everywhere it's documented/ commented: describe.settings.eager_evaluation, not settings.describe.settings.eager_evaluation (matches schema.DescribeSettings.EagerEvaluation's actual yaml/mapstructure tag). - tests/fixtures/scenarios/dependencies-scoped-evaluation/atmos.yaml: components.terraform.base_path now points at the fixture's own local mock component instead of resolving outside the fixture to a shared, unrelated one. - cmd/list/dependencies.go: list dependencies now parses --labels via LabelsRaw on DependenciesOptions (populated in parseDependenciesOptions, parsed in RunE) instead of reading viper directly, matching every other list subcommand's pattern and making the flag wiring unit-testable. - Strengthen tags/labels filter tests (cmd/list/sources_test.go, cmd/list/vendor_test.go, pkg/list/list_instances_test.go, pkg/list/list_metadata_test.go) to assert exact returned rows and cover multi-tag any-match / multi-label all-match distinctly, so a reversed selector semantics bug would be caught. cmd/list/sources.go's `return nil, err` after ParseLabelsFlag was flagged as bypassing the error-wrapping convention, but left as-is: the error is already wrapped with errUtils.ErrInvalidFlag at its origin in pkg/tags/flags.go, and the same passthrough pattern is the established convention in cmd/list/components.go and cmd/list/dependencies.go (8+ call sites) — wrapping only here would diverge from those siblings without a correctness gain. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…dag-closure # Conflicts: # cmd/list/dependencies.go # cmd/list/instances.go
The colon-separator fix updated the --labels flag description everywhere
it's registered ("key=value or key:value pairs" instead of just
"key=value"), which reflows the wrapped --help text captured in these
golden snapshots. Regenerated with -regenerate-snapshots per this repo's
rule against hand-editing golden files; diff is exactly the reflowed
--labels line in each.
Fixes the Acceptance Tests (linux/windows/macos) CI failure — same 7
TestCLICommands subtests failed identically on all three OS matrix jobs
(tf_plan/terraform_provision/terraform/atmos_terraform help snapshots,
config_alias_tr): platform-independent captured CLI text, one fix covers
all three.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
A second flaky autocommit (10061ca) reverted these two modules' URLs to "Unknown" the same way the five modules fixed in 183fb78 did. Rather than keep patching individual gopkg.in modules as they happen to flake, enumerated every gopkg.in/* module actually present in NOTICE (go list -m all | grep gopkg.in, cross-checked against the generated file) — all 7 are now covered. Verified deterministic output across repeated regenerations. Co-Authored-By: Claude Fable 5 <[email protected]>
…nitization
Two independent Windows-only Acceptance Tests failures:
1. TestSanitizeOutput_WithCustomReplacements/Preserve_double-quoted_
provenance_template: sanitizeOutput's filepath.ToSlash(protectedOutput)
call converts every backslash to a forward slash on Windows (a no-op on
Unix), which corrupted literal `\"` sequences in quoted provenance
templates (e.g. `env \"USER\"`) into `/"`. Protect `\"` behind a
placeholder before ToSlash and restore it after, mirroring the existing
JSON-unicode-escape protection immediately above it in the same
function.
2. TestCLICommands/describe_component_with_{current_directory,relative_path,
component_name_(backward_compatibility)}: the "complete" fixture's
provisioned_by_user used `{{ env "USER" }}`. Windows doesn't set USER
(it sets USERNAME), so the template rendered to an empty string, which
serializes as a quoted `""` -- and the sanitizer's provisionedByUserRegex
deliberately excludes quote-leading values (added in b315ec2, to
preserve unresolved quoted templates), so it never got normalized to the
expected `user` placeholder. Add the same fallback to the identical
pattern in the quick-start-advanced example. Golden snapshots
regenerated via -regenerate-snapshots to reflect the new template
source text (the rendered/sanitized line is unchanged).
Co-Authored-By: Claude Fable 5 <[email protected]>
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/cli_test.go`:
- Around line 395-410: Add a regression entry to the TestSanitizeOutput table
using output that contains both escaped quotes (\") and a Unicode escape
(\uXXXX), asserting both sequences remain unchanged after sanitization. Mark or
configure this case to run on Windows so it exercises filepath.ToSlash’s
platform-specific behavior, before relying on the protection logic in the diff.
🪄 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 Plus
Run ID: 5c9d5613-1bf7-48a2-aabf-c9d96c8fccf9
📒 Files selected for processing (7)
examples/quick-start-advanced/stacks/orgs/acme/_defaults.yamlscripts/generate-notice.shtests/cli_test.gotests/fixtures/scenarios/complete/stacks/orgs/cp/_defaults.yamltests/snapshots/TestCLICommands_describe_component_with_component_name_(backward_compatibility).stdout.goldentests/snapshots/TestCLICommands_describe_component_with_current_directory_(.).stdout.goldentests/snapshots/TestCLICommands_describe_component_with_relative_path.stdout.golden
🚧 Files skipped from review as they are similar to previous changes (3)
- tests/snapshots/TestCLICommands_describe_component_with_current_directory_(.).stdout.golden
- tests/snapshots/TestCLICommands_describe_component_with_component_name_(backward_compatibility).stdout.golden
- tests/snapshots/TestCLICommands_describe_component_with_relative_path.stdout.golden
…tpick cleanup `atmos list sources` filtered by --tags/--labels only after describe-stacks had already evaluated auth/templates/YAML-functions for every stack. Switch to ExecuteDescribeStacksScoped so out-of-scope components are skipped before evaluation, matching the scope-before-evaluate pattern already used by the other list commands. Also addresses a few CodeRabbit nitpicks: replace a hand-rolled containsString with slices.Contains in pkg/list/dependencies/scope.go, compute componentTypes once per call instead of once per stack in pkg/list/extract/stacks.go, convert the tags/labels row-filtering subtests in list_instances_test.go and list_metadata_test.go to table-driven tests, and drop the dead filterSpec field/case from TestBuildMetadataFilters. Co-Authored-By: Claude Sonnet 5 <[email protected]>
TestSanitizeOutput had no case exercising the two Windows-only filepath.ToSlash protections (escaped \" and >-style unicode escapes) together, or the > protection at all. Add a regression case with both in one input, per CodeRabbit review on 22a94a4. Only meaningfully exercises the platform-specific path on Windows (ToSlash is a no-op elsewhere), matching how the original bug was only caught by Windows CI. Co-Authored-By: Claude Fable 5 <[email protected]>
…dag-closure Resolved a conflict in scripts/generate-notice.sh: both branches independently fixed the same editorconfig tab-indentation violation in the footer heredoc. Kept this branch's echo-based rewrite (preserves NOTICE's original 2-space visual indent, verified byte-identical across regenerations) over main's simpler tab-substitution (which, while also editorconfig-compliant, would leave those two lines with a much wider indent than the rest of NOTICE). Deduplicated four REPO_OVERRIDES entries (yaml.v2, yaml.v3, op/go-logging.v1, warnings.v0) that both branches had added independently.
…rdening, wrongful-exclusion edges High severity: - --affected --include-dependents=N no longer silently expands unlimited: the selection producer bridged the depth-carrying flag through a bool and left DependentDepth zero (= unlimited in filter encoding), so the most-permissive closure merge erased the user's bound. The new affectedTerraformSelection helper carries the parsed depth from info via the exported FlagDepthToFilterDepth conversion. - Selector purity blast radius: the error now names the offending component and stack manifest; describe.settings.eager_evaluation (the advertised rollback switch) also bypasses purity validation — with full evaluation forced there is no pre-evaluation scoping to protect; docs corrected to state the true enforcement surface (stack-enumerating commands). - Purity gate laundering holes closed: atmos.Resolve (launders any YAML function through a template call), gomplate datasource access beyond ds/datasource (include, datasourceExists, datasourceReachable, defineDatasource), the gomplate aws/gcp/net/random namespaces, and sprig network/nondeterministic functions (getHostByName, uuidv4, randAlpha*, randBytes, now) are now rejected in selectors; map KEYS are validated too. - Wrongful-exclusion edge fixed: RequestedLabels is shape-aware — a non-map labels value (templated scalar) or a templated map key cannot be safely narrowed, so the selector is undecidable and falls through to full evaluation instead of collapsing to a decidable non-match. SelectorUnresolved now also considers map keys. - Reverse-closure blind spot fixed: a dependent whose dependency declaration is templated produces no lightweight-graph edge and was never evaluated, so --include-dependents silently omitted it. Reverse/both directions now conservatively evaluate UnresolvedDependencySources so their edges materialize; membership is still decided by the recomputed closure. Medium severity: - Preview/execution alignment: the final closure re-tests the seed roots against the RESOLVED graph (refineRoots), so a root whose templated selector resolves to a non-matching value is dropped — list previews now match the execution set instead of being a conservative superset. - describe.settings.eager_evaluation documented on the website (cli/configuration/describe) and referenced from the blog post as the migration escape hatch for the purity contract; blog also documents the --affected --include-dependents --tags scope-semantics change and the bare-flag depth syntax sharp edge. Low severity: - list vendor --tags binds ATMOS_VENDOR_TAGS instead of reusing ATMOS_COMPONENT_TAGS for a semantically different filter (vendor manifest tags, not component metadata.tags). - list metadata docs no longer advertise the not-yet-implemented --filter expression; examples use jq over --format json instead. Tests added: - --affected selection depth table (bare/bounded/forced/nil-info) and a closure-spec merge case pinning that same-flag inputs keep the bound. - Purity: ~20 deny-list cases including allowed-direction guards (.vars.aws/.vars.now stay legal), map-key rejection, and the documented .vars.Component conservatism; eager_evaluation bypass; error identity. - Wrongful exclusion: templated-scalar labels and templated label keys fall through to full evaluation at the processor level. - Reverse closure: templated same-stack and cross-stack dependents are discovered; evaluated non-dependents stay out of the closure; forward direction skips the conservative evaluation entirely. - Preview drift: resolved-to-non-matching root is dropped from the closure. - Cross-stack execution ordering through ExecuteTerraform (vpc-core before app-dev; reversed for destroy) and destroy --include-dependencies ordering (seed first, prerequisites last). - Destroy --include-dependencies warning presence/absence via the UI-stream capture seam; not-provisioned state-cache invalidation including mismatched-key negative guards. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
website/docs/stacks/components/metadata.mdx (1)
324-333: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winClarify the selector evaluation boundary.
Line 326 says selectors are evaluated before all template processing and YAML function execution, but Lines 331-332 allow simple Go templates and local YAML functions. State that selectors use a restricted pre-authentication phase before full template/YAML evaluation.
Proposed wording
-Labels and tags are selectors: Atmos evaluates them **before** authentication, template processing, and YAML function execution to decide which components a command operates on. +Labels and tags are selectors: Atmos resolves them in a restricted pre-authentication phase, before authentication and full template/YAML evaluation, to decide which components a command operates on.🤖 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 `@website/docs/stacks/components/metadata.mdx` around lines 324 - 333, Clarify the “Selector Purity” description to distinguish restricted pre-authentication evaluation from full template and YAML processing. Update the paragraph near “metadata.tags” and “metadata.labels” to state that only the supported simple templates and local YAML functions are resolved in this restricted phase, while authentication, external processes, and full evaluation remain deferred.
🧹 Nitpick comments (1)
pkg/list/dependencies/scope.go (1)
260-271: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the
Selectorconstruction into aScopeRequestmethod.This literal duplicates the one in
ResolveScopedClosure. If a future selector field is added toScopeRequest, one of the two sites will be missed and the refined roots will use a weaker selector than the seed pass. A small helper keeps both passes identical by construction.♻️ Proposed refactor
+// selector builds the seed selector for this request. Both the lightweight +// seed pass and the resolved-graph refinement must use the same filters. +func (r *ScopeRequest) selector() *Selector { + return &Selector{ + Components: r.Components, + Stack: r.Stack, + Tags: r.Tags, + Labels: r.Labels, + LeftDelim: r.LeftDelim, + RightDelim: r.RightDelim, + } +}- sel := &Selector{ - Components: req.Components, - Stack: req.Stack, - Tags: req.Tags, - Labels: req.Labels, - LeftDelim: req.LeftDelim, - RightDelim: req.RightDelim, - } + sel := req.selector()🤖 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 `@pkg/list/dependencies/scope.go` around lines 260 - 271, Extract the duplicated Selector construction from refineRoots into a method on ScopeRequest, then reuse that method in both refineRoots and ResolveScopedClosure. Ensure the helper maps all selector-related ScopeRequest fields so root refinement and seed resolution remain identical as fields evolve.
🤖 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 `@website/docs/cli/configuration/describe.mdx`:
- Around line 49-59: Update the selector purity link in the
settings.eager_evaluation documentation to use the current
/stacks/components/metadata#selector-purity destination instead of the outdated
component-metadata path.
---
Outside diff comments:
In `@website/docs/stacks/components/metadata.mdx`:
- Around line 324-333: Clarify the “Selector Purity” description to distinguish
restricted pre-authentication evaluation from full template and YAML processing.
Update the paragraph near “metadata.tags” and “metadata.labels” to state that
only the supported simple templates and local YAML functions are resolved in
this restricted phase, while authentication, external processes, and full
evaluation remain deferred.
---
Nitpick comments:
In `@pkg/list/dependencies/scope.go`:
- Around line 260-271: Extract the duplicated Selector construction from
refineRoots into a method on ScopeRequest, then reuse that method in both
refineRoots and ResolveScopedClosure. Ensure the helper maps all
selector-related ScopeRequest fields so root refinement and seed resolution
remain identical as fields evolve.
🪄 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 Plus
Run ID: b04bf176-a9a9-41d5-80d4-2e55d30b4722
📒 Files selected for processing (22)
cmd/list/flag_wrappers.gocmd/list/vendor.gocmd/terraform/utils_test.goerrors/errors.gointernal/exec/describe_stacks_component_processor.gointernal/exec/describe_stacks_component_processor_scope_test.gointernal/exec/terraform_affected.gointernal/exec/terraform_affected_test.gointernal/exec/terraform_state_output_coverage_test.gopkg/list/dependencies/build.gopkg/list/dependencies/render.gopkg/list/dependencies/scope.gopkg/list/dependencies/scope_test.gopkg/scheduler/adapters/terraform.gopkg/scheduler/adapters/terraform_closure_test.gopkg/tags/selector.gopkg/tags/selector_test.gowebsite/blog/2026-07-27-include-dependencies-closure.mdxwebsite/docs/cli/commands/list/list-metadata.mdxwebsite/docs/cli/commands/list/list-vendor.mdxwebsite/docs/cli/configuration/describe.mdxwebsite/docs/stacks/components/metadata.mdx
🚧 Files skipped from review as they are similar to previous changes (6)
- errors/errors.go
- pkg/tags/selector_test.go
- cmd/list/vendor.go
- pkg/list/dependencies/render.go
- internal/exec/describe_stacks_component_processor.go
- cmd/list/flag_wrappers.go
Extract the Selector construction shared by the lightweight seed pass (ResolveScopedClosure) and the resolved-graph root refinement (refineRoots) into a ScopeRequest.selector() method. The refinement must apply exactly the same filters as the seed pass; constructing them in one place keeps the two passes identical by construction when a selector field is added. Addresses a CodeRabbit review comment on PR #2807. Co-Authored-By: Claude Fable 5 <[email protected]>
|
CodeRabbit (@coderabbitai) full review please, and analyze in more details the last two commits (from Andriy Knysh (@aknysh)) for correctness |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== PR commits, newest first =="
gh api repos/cloudposse/atmos/pulls/2807/commits --paginate \
--jq '.[] | [.sha[0:12], .commit.author.name, .commit.author.email, .commit.message | split("\n")[0]] | `@tsv`' \
| tac
echo
echo "== Last two commits authored by aknysh =="
mapfile -t shas < <(
gh api repos/cloudposse/atmos/pulls/2807/commits --paginate \
--jq '.[] | select((.author.login? // "") == "aknysh" or (.commit.author.name | ascii_downcase | contains("aknysh"))) | .sha' \
| tail -n 2
)
printf '%s\n' "${shas[@]}"
for sha in "${shas[@]}"; do
echo
echo "== Commit ${sha} =="
git show --no-ext-diff --format=fuller --stat "$sha"
echo "-- Changed files --"
git diff-tree --no-commit-id --name-status -r "$sha"
echo "-- Diff --"
git show --no-ext-diff --format= --find-renames --find-copies "$sha"
doneLength of output: 7140 🏁 Script executed: #!/bin/bash
set -euo pipefail
for sha in b32eb87b1915 bf5cb33871b7; do
echo
echo "== ${sha}: commit metadata and changed files =="
git show --no-ext-diff --format=fuller --stat --summary "$sha"
echo
echo "== ${sha}: patch =="
git show --no-ext-diff --format= --find-renames --find-copies "$sha"
done
echo
echo "== Changed Go-file outlines =="
for sha in b32eb87b1915 bf5cb33871b7; do
git diff-tree --no-commit-id --name-only -r "$sha" -- '*.go' \
| while IFS= read -r file; do
[ -n "$file" ] || continue
echo "-- ${sha} :: ${file} --"
ast-grep outline "$file" --items all --type function,method,struct,interface 2>/dev/null || true
done
doneLength of output: 111681 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Scoped closure implementation =="
sed -n '80,390p' pkg/list/dependencies/scope.go
echo
echo "== Scoped closure callers and result consumption =="
rg -n -C 6 'ResolveScopedClosure\s*\(|ScopeResult|\.Closure\b|\.Stacks\b' \
cmd internal pkg \
-g '*.go'
echo
echo "== Dependency graph closure semantics =="
sed -n '1,230p' pkg/list/dependencies/closure.go
sed -n '280,470p' pkg/scheduler/adapters/terraform.go
echo
echo "== Selector matching and current purity parsing =="
sed -n '100,540p' pkg/tags/selector.go
sed -n '750,875p' internal/exec/describe_stacks_component_processor.go
echo
echo "== Relevant current tests =="
sed -n '150,380p' pkg/list/dependencies/scope_test.go
sed -n '430,640p' pkg/list/dependencies/scope_test.go
sed -n '210,290p' pkg/scheduler/adapters/terraform_closure_test.goLength of output: 127434 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Direct scoped-closure call sites =="
rg -n -C 18 'ResolveScopedClosure\s*\(' cmd internal pkg -g '*.go'
echo
echo "== Components closure path =="
ast-grep outline cmd/list/components.go --items all --type function,method --match 'Closure|Extract|Components'
rg -n -C 20 'ResolveScopedClosure|ComponentNames|IncludeDependencies|IncludeDependents|filterRowsByComponentNames' \
cmd/list/components.go
echo
echo "== Stacks closure path =="
ast-grep outline cmd/list/stacks.go --items all --type function,method --match 'Closure|Stacks|Extract'
rg -n -C 20 'ResolveScopedClosure|ComponentNames|IncludeDependencies|IncludeDependents|extract\.Stacks' \
cmd/list/stacks.go
echo
echo "== Dependencies closure path =="
ast-grep outline cmd/list/dependencies.go --items all --type function,method --match 'Closure|Dependency|Graph'
rg -n -C 20 'ResolveScopedClosure|result\.Stacks|result\.Closure|BuildGraph' \
cmd/list/dependencies.go
echo
echo "== Terraform scoped-closure execution path =="
rg -n -C 20 'ResolveScopedClosure|result\.Stacks|result\.Closure|describeTerraformStacksForExecution' \
internal/exec/terraform_all.go internal/exec/terraform_query.goLength of output: 86258
In reverse or both-direction closure resolution, As a result, The selector refactor in I will now run the requested full review. ✅ Action performedFull review finished. |
internal/exec/describe_stacks_component_processor.go:853 was flagged by nestif (complexity: 4). Extracts the label-narrowing/resolution block from inScopeByTagsAndLabelsWithContext into a named helper, resolveLabelSelector, preserving behavior exactly. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (7)
pkg/list/list_instances_authdisabled_test.go (1)
164-182: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider one more case: filters set, but the processor has no scoped method.
executeDescribeStacksForInstancesnow has three dispatch branches, and the new scoped branch is the first one. These tests always passnilfor both filters, so the scoped branch never runs. The documented fail-open contract ("A processor without the optional scoped interface simply describes unscoped") is therefore untested.authDisabledFakeProcessordoes not implementExecuteDescribeStacksScoped, so adding a case with non-nil filters covers the fallback cheaply.♻️ Suggested additional test
// TestExecuteDescribeStacksForInstances_ScopedFiltersFallBackWhenUnsupported asserts // that tags/labels filters do not break dispatch for a processor without the // optional scoped interface: the run must fall through to the auth-disabled path. func TestExecuteDescribeStacksForInstances_ScopedFiltersFallBackWhenUnsupported(t *testing.T) { fake := &authDisabledFakeProcessor{} atmosConfig := &schema.AtmosConfiguration{} _, err := executeDescribeStacksForInstances( atmosConfig, fake, nil, // authManager true, // processTemplates true, // processYamlFunctions nil, // skip true, // authDisabled []string{"production"}, // tagsFilter map[string]string{"env": "prod"}, // labelsFilter ) require.NoError(t, err) assert.True(t, fake.executeDescribeStacksAuthDisabled, "a processor without the scoped interface must fall back to the auth-disabled path") }🤖 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 `@pkg/list/list_instances_authdisabled_test.go` around lines 164 - 182, Add a test covering non-nil tags and labels filters when using authDisabledFakeProcessor, which lacks ExecuteDescribeStacksScoped. Invoke executeDescribeStacksForInstances with authDisabled enabled and assert no error plus executeDescribeStacksAuthDisabled is called, verifying fallback to the auth-disabled path.pkg/list/list_instances_coverage_test.go (1)
609-621: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftAssert the rendered closure set, not only the absence of an error.
The doc comment states the test must render the istio chain plus its forward prerequisites and never
eks/karpenter. The only assertion isrequire.NoError, so a closure regression that returns every component in the stack still passes. Capture the JSON output through thedatawriter and assert the component set.The same gap applies to nothing else in this file; the error-propagation test below does assert its specific message.
🤖 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 `@pkg/list/list_instances_coverage_test.go` around lines 609 - 621, Strengthen the test around ExecuteListInstancesCmd by capturing its JSON output via the data writer and decoding the rendered component set. Assert that it contains the istio chain and forward prerequisites while excluding eks/karpenter, in addition to retaining the existing require.NoError check.pkg/list/extract/components_test.go (1)
716-737: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse table-driven tests for the metadata cases.
Each new test function contains multiple scenarios as separate subtests. Convert both groups to table-driven tests. Include mixed invalid entries and values to verify the filtering behavior.
As per coding guidelines, use table-driven tests for testing multiple scenarios in Go.
Also applies to: 739-760
🤖 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 `@pkg/list/extract/components_test.go` around lines 716 - 737, Refactor the metadata accessor tests around TestGetTagsFromMetadata into table-driven cases instead of separate scenario subtests. Include valid tags, absent and wrong-type metadata, plus mixed valid and invalid entries/values to verify filtering, while preserving assertions that invalid or missing input returns an empty non-nil slice.Source: Coding guidelines
internal/exec/describe_stacks.go (1)
256-272: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftReplace the expanded positional API with functional options.
The selector filters add more positional arguments to an already large call chain. This makes caller mistakes hard to detect and violates the Go command guidelines.
internal/exec/describe_stacks.go#L256-L272: replacetagsFilterandlabelsFilterparameters with scope options.internal/exec/describe_stacks.go#L353-L372: expose the scoped operation through the same options-based API.internal/exec/describe_stacks.go#L376-L414: pass a single options value to the internal processor setup.As per coding guidelines, “Use the functional options pattern for configuration instead of functions with many parameters.”
🤖 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 `@internal/exec/describe_stacks.go` around lines 256 - 272, Replace the positional tagsFilter and labelsFilter parameters with functional scope options across internal/exec/describe_stacks.go:256-272, including ExecuteDescribeStacksWithMocks; expose the same options-based API in the operation around lines 353-372; and pass one options value into the internal processor setup around lines 376-414 instead of separate selector arguments. Preserve existing selector behavior while consolidating configuration through the functional-options pattern.Source: Coding guidelines
pkg/list/list_metadata.go (1)
175-178: 📐 Maintainability & Code Quality | 🔵 TrivialTODO:
--filterspec not yet honored for metadata.The comment marks
--filtersupport forlist metadataas unimplemented. Do you want me to draft a solution that extendsbuildMetadataFiltersto also honor--filteronce its format is defined, or open a new issue to track this?🤖 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 `@pkg/list/list_metadata.go` around lines 175 - 178, The metadata filter builder currently ignores the `--filter` specification. Once the filter format is defined, update `buildMetadataFilters` to parse and apply `--filter` alongside the existing `--tags` and `--labels` filters, preserving their current matching semantics.pkg/list/dependencies/render_test.go (1)
138-169: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider naming the two selector cases and building
appmetadata in the fixture.Two small readability points here. The loop runs two different selectors without subtests, so a failure does not say whether tags or labels failed. Also,
appmetadata is injected through a chain of type assertions on the fixture map, which duplicates knowledge of the fixture shape.♻️ Suggested shape
- app := stacks["dev"].(map[string]any)["components"].(map[string]any)["terraform"].(map[string]any)["app"].(map[string]any) - app["metadata"] = map[string]any{ - "tags": []any{"application"}, - "labels": map[string]any{"team": "platform", "environment": "test"}, - } graph, err := BuildGraph(stacks) require.NoError(t, err) - for _, opts := range []Options{ - {Format: FormatLevels, Direction: DirectionForward, Tags: []string{"application", "tier-1"}}, - {Format: FormatLevels, Direction: DirectionForward, Labels: map[string]string{"team": "platform", "environment": "test"}}, - } { - out, err := Render(graph, opts) - require.NoError(t, err) - assertLevel(t, out, "app", 0) - assertLevel(t, out, "vpc", 1) - assert.NotContains(t, out, "ignored") - } + for _, tc := range []struct { + name string + opts Options + }{ + {"tags_root", Options{Format: FormatLevels, Direction: DirectionForward, Tags: []string{"application", "tier-1"}}}, + {"labels_root", Options{Format: FormatLevels, Direction: DirectionForward, Labels: map[string]string{"team": "platform", "environment": "test"}}}, + } { + t.Run(tc.name, func(t *testing.T) { + out, err := Render(graph, tc.opts) + require.NoError(t, err) + assertLevel(t, out, "app", 0) + assertLevel(t, out, "vpc", 1) + assert.NotContains(t, out, "ignored") + }) + }Set the
appmetadata (tags plus labels) in the fixture map next to itsdependencies, so the test reads top to bottom.🤖 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 `@pkg/list/dependencies/render_test.go` around lines 138 - 169, Improve TestRender_LevelsHonorsTagsAndAllLabelsForRoots by defining the app metadata directly in the terraformStacks fixture alongside its dependencies, removing the subsequent chained type assertions and mutation. Name the two Options cases and run them as subtests so failures identify whether tag or label selection failed.pkg/tags/selector_test.go (1)
436-478: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove the alternate fixture into the table instead of branching on the case name.
The
tc.name == "nested_template_output_unresolved"check ties behavior to a string. If someone renames that case, the test silently exercises the wrong data and still passes.♻️ Proposed refactor
tests := []struct { name string v any + data map[string]any want any resolved bool }{ @@ - {name: "nested_template_output_unresolved", v: "{{ .vars.templated }}", resolved: false}, + {name: "nested_template_output_unresolved", v: "{{ .vars.templated }}", data: dataWithTemplated, resolved: false}, @@ - input := data - if tc.name == "nested_template_output_unresolved" { - input = dataWithTemplated - } + input := data + if tc.data != nil { + input = tc.data + } got, resolved := ResolveSelectorValue(tc.v, input, "", "")Declare
dataWithTemplatedabove the table so the literal can reference it.🤖 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 `@pkg/tags/selector_test.go` around lines 436 - 478, Update the table-driven test around the tests slice so each case carries its own input data, using the existing dataWithTemplated fixture for nested_template_output_unresolved and the default fixture for other cases. Remove the tc.name comparison and input reassignment inside the subtest.
🤖 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 `@cmd/list/sources_test.go`:
- Around line 82-83: Update the fetchAndFilterSources error assertion to verify
errors.Is against errUtils.ErrInvalidFlag, preserving the wrapped-error behavior
from tags.ParseLabelsFlag instead of only checking that an error occurred. Add
the errUtils import if needed and use the existing test assertion style to
validate the specific error identity.
In `@cmd/list/stacks.go`:
- Around line 356-395: Update extractStacksViaScopedClosure so each
closure-extracted row includes the selected component value under the
"component" key, matching the non-closure --component path. Add opts.Component
to the row data before returning stacks, while preserving existing stack and
vars values and behavior when no component is selected.
In `@pkg/list/list_instances_coverage_test.go`:
- Around line 103-112: Update the test around ExecuteListInstancesCmd to assert
the specific malformed-label parse error returned by tags.ParseLabelsFlag,
rather than accepting any error. Use errors.Is() to verify the appropriate
sentinel and assert the expected error message, adjusting the sentinel to the
parser’s actual malformed-pair error.
In
`@tests/snapshots/TestCLICommands_describe_component_with_relative_path.stdout.golden`:
- Line 1039: Update the golden snapshot test setup for
TestCLICommands_describe_component_with_relative_path so both USER and USERNAME
are explicitly set to the fixed value “user” before rendering the snapshot,
ensuring provisioned_by_user remains portable across platforms and environments.
In
`@tests/snapshots/TestCLICommands_terraform_help_shows_stack_flag.stdout.golden`:
- Around line 86-90: Update the source help text for the Terraform closure flags
near the include-dependencies/include-dependents descriptions to document that
destroy operations reverse dependency order, with dependents destroyed before
prerequisites. Regenerate the
TestCLICommands_terraform_help_shows_stack_flag.stdout.golden snapshot so it
matches the updated help output.
In `@website/docs/cli/commands/list/list-dependencies.mdx`:
- Around line 124-125: Update the level-0 seed description near the `Level`
definition to include the positional `component` argument alongside `--stack`,
`--tags`, and `--labels`, accurately documenting that all these selectors seed
level 0.
---
Nitpick comments:
In `@internal/exec/describe_stacks.go`:
- Around line 256-272: Replace the positional tagsFilter and labelsFilter
parameters with functional scope options across
internal/exec/describe_stacks.go:256-272, including
ExecuteDescribeStacksWithMocks; expose the same options-based API in the
operation around lines 353-372; and pass one options value into the internal
processor setup around lines 376-414 instead of separate selector arguments.
Preserve existing selector behavior while consolidating configuration through
the functional-options pattern.
In `@pkg/list/dependencies/render_test.go`:
- Around line 138-169: Improve TestRender_LevelsHonorsTagsAndAllLabelsForRoots
by defining the app metadata directly in the terraformStacks fixture alongside
its dependencies, removing the subsequent chained type assertions and mutation.
Name the two Options cases and run them as subtests so failures identify whether
tag or label selection failed.
In `@pkg/list/extract/components_test.go`:
- Around line 716-737: Refactor the metadata accessor tests around
TestGetTagsFromMetadata into table-driven cases instead of separate scenario
subtests. Include valid tags, absent and wrong-type metadata, plus mixed valid
and invalid entries/values to verify filtering, while preserving assertions that
invalid or missing input returns an empty non-nil slice.
In `@pkg/list/list_instances_authdisabled_test.go`:
- Around line 164-182: Add a test covering non-nil tags and labels filters when
using authDisabledFakeProcessor, which lacks ExecuteDescribeStacksScoped. Invoke
executeDescribeStacksForInstances with authDisabled enabled and assert no error
plus executeDescribeStacksAuthDisabled is called, verifying fallback to the
auth-disabled path.
In `@pkg/list/list_instances_coverage_test.go`:
- Around line 609-621: Strengthen the test around ExecuteListInstancesCmd by
capturing its JSON output via the data writer and decoding the rendered
component set. Assert that it contains the istio chain and forward prerequisites
while excluding eks/karpenter, in addition to retaining the existing
require.NoError check.
In `@pkg/list/list_metadata.go`:
- Around line 175-178: The metadata filter builder currently ignores the
`--filter` specification. Once the filter format is defined, update
`buildMetadataFilters` to parse and apply `--filter` alongside the existing
`--tags` and `--labels` filters, preserving their current matching semantics.
In `@pkg/tags/selector_test.go`:
- Around line 436-478: Update the table-driven test around the tests slice so
each case carries its own input data, using the existing dataWithTemplated
fixture for nested_template_output_unresolved and the default fixture for other
cases. Remove the tc.name comparison and input reassignment inside the subtest.
🪄 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 Plus
Run ID: c15319e7-0187-4480-95b0-33ec147c4d8e
📒 Files selected for processing (148)
.claude/settings.jsonNOTICEcmd/container/verbs.gocmd/helm/helm.gocmd/kubernetes/kubernetes.gocmd/list/closure_test.gocmd/list/cmd_executor_integration_test.gocmd/list/components.gocmd/list/components_closure_test.gocmd/list/components_test.gocmd/list/dependencies.gocmd/list/dependencies_scoped_test.gocmd/list/flag_wrappers.gocmd/list/flag_wrappers_test.gocmd/list/instances.gocmd/list/instances_test.gocmd/list/metadata.gocmd/list/parse_options_test.gocmd/list/sources.gocmd/list/sources_test.gocmd/list/stacks.gocmd/list/stacks_closure_test.gocmd/list/vendor.gocmd/list/vendor_test.gocmd/terraform/flags.gocmd/terraform/flags_test.gocmd/terraform/options.gocmd/terraform/options_test.gocmd/terraform/utils.gocmd/terraform/utils_test.godocs/fixes/2026-07-25-scope-before-evaluate-labels-tags-list-dependencies.mderrors/errors.goexamples/quick-start-advanced/stacks/orgs/acme/_defaults.yamlinternal/exec/describe_affected.gointernal/exec/describe_affected_test.gointernal/exec/describe_stacks.gointernal/exec/describe_stacks_component_processor.gointernal/exec/describe_stacks_component_processor_scope_test.gointernal/exec/describe_stacks_component_processor_test.gointernal/exec/describe_stacks_test.gointernal/exec/filter_utils.gointernal/exec/stacks_processor.gointernal/exec/stacks_processor_test.gointernal/exec/terraform_affected.gointernal/exec/terraform_affected_test.gointernal/exec/terraform_all.gointernal/exec/terraform_all_closure_scope_test.gointernal/exec/terraform_query.gointernal/exec/terraform_state_output_coverage_test.gointernal/exec/terraform_state_utils.gointernal/exec/terraform_utils_test.gointernal/exec/utils.gointernal/exec/utils_test.gopkg/datafetcher/schema/atmos/config/1.0.jsonpkg/dependency/filter.gopkg/dependency/filter_test.gopkg/dependency/types.gopkg/flags/depth.gopkg/flags/depth_test.gopkg/list/dependencies/build.gopkg/list/dependencies/closure.gopkg/list/dependencies/closure_test.gopkg/list/dependencies/render.gopkg/list/dependencies/render_test.gopkg/list/dependencies/scope.gopkg/list/dependencies/scope_test.gopkg/list/extract/components.gopkg/list/extract/components_test.gopkg/list/extract/metadata.gopkg/list/extract/metadata_test.gopkg/list/extract/stacks.gopkg/list/extract/stacks_test.gopkg/list/extract/vendor.gopkg/list/extract/vendor_test.gopkg/list/filter/filter.gopkg/list/filter/filter_test.gopkg/list/list_instances.gopkg/list/list_instances_authdisabled_test.gopkg/list/list_instances_closure_test.gopkg/list/list_instances_coverage_test.gopkg/list/list_instances_process_test.gopkg/list/list_instances_test.gopkg/list/list_metadata.gopkg/list/list_metadata_test.gopkg/scheduler/adapters/terraform.gopkg/scheduler/adapters/terraform_closure_test.gopkg/scheduler/adapters/terraform_test.gopkg/schema/schema.gopkg/schema/schema_test.gopkg/tags/flags.gopkg/tags/flags_test.gopkg/tags/selector.gopkg/tags/selector_test.goscripts/generate-notice.shtests/cli_sanitize_test.gotests/cli_test.gotests/fixtures/scenarios/complete/stacks/orgs/cp/_defaults.yamltests/fixtures/scenarios/dependencies-scoped-evaluation/atmos.yamltests/fixtures/scenarios/dependencies-scoped-evaluation/components/terraform/mock/main.tftests/fixtures/scenarios/dependencies-scoped-evaluation/stacks/deploy/app-a.yamltests/fixtures/scenarios/dependencies-scoped-evaluation/stacks/deploy/app-b.yamltests/fixtures/scenarios/list-components-closure-tags/atmos.yamltests/fixtures/scenarios/list-components-closure-tags/stacks/deploy/broken.yamltests/fixtures/scenarios/list-components-closure-tags/stacks/deploy/prod.yamltests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.goldentests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.goldentests/snapshots/TestCLICommands_atmos_terraform_help.stdout.goldentests/snapshots/TestCLICommands_config_alias_tr_--help_shows_terraform_help.stdout.goldentests/snapshots/TestCLICommands_describe_component_with_component_name_(backward_compatibility).stdout.goldentests/snapshots/TestCLICommands_describe_component_with_current_directory_(.).stdout.goldentests/snapshots/TestCLICommands_describe_component_with_relative_path.stdout.goldentests/snapshots/TestCLICommands_terraform_help_shows_stack_flag.stdout.goldentests/snapshots/TestCLICommands_terraform_provision_help_shows_inherited_stack_flag.stdout.goldentests/snapshots/TestCLICommands_tf_plan_help_shows_inherited_stack_flag.stdout.goldentests/test-cases/component-path-resolution.yamlwebsite/blog/2026-07-27-include-dependencies-closure.mdxwebsite/docs/cli/commands/container/usage.mdxwebsite/docs/cli/commands/helm/helm-apply.mdxwebsite/docs/cli/commands/helm/helm-delete.mdxwebsite/docs/cli/commands/helm/helm-deploy.mdxwebsite/docs/cli/commands/helm/helm-diff.mdxwebsite/docs/cli/commands/helm/helm-plan.mdxwebsite/docs/cli/commands/helm/helm-template.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-apply.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-delete.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-deploy.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-diff.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-plan.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-render.mdxwebsite/docs/cli/commands/kubernetes/kubernetes-validate.mdxwebsite/docs/cli/commands/kubernetes/usage.mdxwebsite/docs/cli/commands/list/list-components.mdxwebsite/docs/cli/commands/list/list-dependencies.mdxwebsite/docs/cli/commands/list/list-instances.mdxwebsite/docs/cli/commands/list/list-metadata.mdxwebsite/docs/cli/commands/list/list-sources.mdxwebsite/docs/cli/commands/list/list-stacks.mdxwebsite/docs/cli/commands/list/list-vendor.mdxwebsite/docs/cli/commands/terraform/terraform-apply.mdxwebsite/docs/cli/commands/terraform/terraform-deploy.mdxwebsite/docs/cli/commands/terraform/terraform-destroy.mdxwebsite/docs/cli/commands/terraform/terraform-init.mdxwebsite/docs/cli/commands/terraform/terraform-plan.mdxwebsite/docs/cli/commands/terraform/usage.mdxwebsite/docs/cli/configuration/describe.mdxwebsite/docs/stacks/components/metadata.mdxwebsite/src/data/roadmap.jswebsite/static/casts/screengrabs/atmos-list-dependencies--help.cast
💤 Files with no reviewable changes (2)
- tests/test-cases/component-path-resolution.yaml
- .claude/settings.json
…review comments CodeRabbit review fixes on PR #2807: list stacks closure correctness: - `list stacks --include-*` output is now restricted to the FINAL closure's stacks before extraction. result.Stacks can hold conservatively evaluated stacks that are not closure members (the reverse direction evaluates unresolved dependency sources so their edges materialize, and refineRoots can drop an initially conservative root once its selector resolves) — list components/instances already filtered by closure membership; stacks now does too, so the preview matches the execution set. Regression-tested with a new qa fixture stack whose templated dependency resolves outside the closure (test fails with the filter removed). - With --component, closure-extracted stack rows now carry the component under "component" for stacks that actually contain it, matching extract.StacksForComponent's row shape so `{{ .component }}` columns render identically with and without closure flags. Prerequisite stacks without the component keep no component key rather than claiming one. Help text and docs: - The --include-dependencies/--include-dependents descriptions now state the order is reversed for destroy; 7 terraform help golden snapshots regenerated via -regenerate-snapshots. - list dependencies levels doc: the positional component argument is now listed among the level-0 seeds alongside --stack/--tags/--labels. Test hardening: - USER and USERNAME pinned to "user" in all three component-path-resolution test cases that snapshot provisioned_by_user: the sanitizer regex cannot cover a username containing spaces or both vars being unset, so the snapshots were portable only by accident. Snapshots regenerated (byte-identical — the pinning makes the sanitized value genuine). - Invalid --labels tests (cmd/list sources, pkg/list instances) now assert errUtils.ErrInvalidFlag and the offending value, not just any error. - Added the fail-open scoped-dispatch test: tags/labels filters with a processor lacking the optional scoped interface fall back cleanly. - The instances closure-preview test now captures the data stream and asserts the exact rendered component set instead of only NoError. - GetTagsFromMetadata/GetLabelsFromMetadata tests converted to table-driven with mixed-type cases; render levels selector cases named as subtests with the fixture built inline; ResolveSelectorValue test's name-string branch replaced with a per-case data field. - Removed a //nolint:dupl directive made unused by the strengthened test. Deferred with follow-up issues to be opened: functional-options migration for the ExecuteDescribeStacks* family (heavy refactor, wrong to do mid-review) and honoring --filter in list metadata (feature gap, docs already corrected). Co-Authored-By: Claude Fable 5 <[email protected]>
TestCheckTerraformFlagsDestroyDependenciesWarning asserted plain text on the captured UI stream. Locally (non-TTY) the warning renders unstyled and the test passed; on CI (all three OSes) the formatter renders the stream with ANSI colors and width-dependent style segmentation — the sentence is split across styled segments (`...the selected\x1b[0m\x1b[97m components`) — so the Contains assertion failed. Strip ANSI escape sequences and collapse all whitespace (including wrap-inserted newlines) before asserting, in both the positive and negative directions. Verified against the exact CI-captured byte sequence and under ATMOS_FORCE_COLOR=true ATMOS_FORCE_TTY=true COLUMNS=80. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
Warning Release Documentation RequiredThis PR is labeled
|
|
These changes were released in v1.225.0-rc.5. |
what
Dependency-closure selection (new)
--all,--components,--query,-s,--tags,--labels,--affected) accepts two new depth-carrying flags onplan/apply/deploy/destroy/init:--include-dependencies[=N]— also process everything the selection depends on (its prerequisites), N levels deep (bare flag = unlimited).--include-dependents[=N]— the reverse direction. Previously a bool wired only into--affected; now works with every selection and accepts a depth (true/falseremain accepted for compatibility).destroy --include-dependencieswarns that it also destroys shared prerequisites.atmos list components/stacks/instancespreview the exact execution set a bulk run would touch.pkg/dependency.Filtergains per-direction depth bounds with a best-depth BFS; the scheduler adapter is restructured to seed-then-expand (tags/labels/query moved from post-filter to seed narrowing, per-node query skip suppressed when the seed already applied it).list dependenciesis generalized intodependencies.ResolveScopedClosureand shared with the terraform bulk paths, so closure runs fully evaluate only the stacks the closure touches.Selector purity (new, by design)
metadata.tags/metadata.labelsare selectors evaluated before auth/templating/YAML functions, so their values must be resolvable without authentication or process execution. Values using!terraform.state,!terraform.output,!store,!store.get,!secret,!aws.*,!emulator,!exec,!random, or template calls toatmos.Component/atmos.Store/atmos.GomplateDatasource/datasources are rejected with a by-design error and migration hint on any command that processes the manifest. Plain strings, simple templates, and local functions (!env,!git.*,!include) remain allowed.templates.settings.delimiters) via Go's template parser — no regex heuristics — andtags.SelectorUnresolvedis now delimiter-aware too.Scope-before-evaluate for
--labels/--tags(original scope)--tags/--labelsskips auth/template/YAML-function evaluation entirely, generalizing the existing-s/--stackearly-skip. Now also threaded intolist stacks/components/instances(previously they row-filtered after full evaluation).atmos list dependenciescomputes a lightweight dependency graph, derives the reachable closure, and only fully evaluates the stacks that closure touches — re-converging against the resolved graph so templated same-stack dependency targets still resolve.describe.settings.eager_evaluationremains the rollback switch forcing the old full-evaluation behavior.Tests and docs
pkg/tags(purity + delimiter cases),pkg/dependency(depth/cycles/diamonds),pkg/scheduler/adapters(closure retains non-matching prereqs, destroy ordering, query suppression, depth merging),pkg/list/dependencies(scoped-evaluation convergence with a poisoned unrelated stack), and the list/cmd layers; regenerated help-text golden snapshots.website/blog/2026-07-27-include-dependencies-closure.mdx), and a roadmap entry.why
atmos terraform ... --all --labels=.../--tags=...andatmos list dependencies --stack <stack>fully evaluated every stack in the repo (templates, YAML functions, auth/backend) before consulting the selector, so an unrelated account's unreachable backend failed the command.references
docs/fixes/2026-06-22-describe-stacks-scope-and-cache-per-component-auth.md.docs/fixes/2026-07-25-scope-before-evaluate-labels-tags-list-dependencies.mdfor root-cause and verification detail of the scope-before-evaluate work (its Recommendations section is implemented by this PR's closure flags).🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
levelsoutput for shortest dependency distances.key=valueandkey:valueformats.Improvements