-
-
Notifications
You must be signed in to change notification settings - Fork 151
fix: Resolve multiple regressions and reported issues #2035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
bf70a89
fix: Resolve template regression with {{ .atmos_component }} in non-.…
aknysh 82f9336
fix: Add --verify=false to helm plugin install in Dockerfile
aknysh b290594
fix: propagate AuthManager to YAML functions in terraform shell command
aknysh 0e7c438
docs: add date to fix documentation files
aknysh b71eb42
update packages
aknysh 1d11c47
fix: correctly parse YAML strings ending with colons in yq expressions
aknysh 1dff997
fix: add JIT vendoring support to generate varfile and generate backend
aknysh 028146a
fix: support quoted two-word terraform commands like "providers lock"
aknysh 9b3dc6a
fix: route shell subcommand correctly when invoked from Atmos UI
aknysh 0f181b6
fix: enable settings to reference locals in stack manifests
aknysh 7e3071b
test: increase test coverage for branch changes
aknysh 404b884
fix: make new tests Windows-compatible
aknysh 0f57abb
fix: resolve locals and spacelift_stack templates in describe component
aknysh eb56bbf
update tests
aknysh f12d993
update docs
aknysh 6867784
[autofix.ci] apply automated fixes
autofix-ci[bot] 2cc8323
fix: address CodeRabbit review comments and improve test coverage
aknysh b95ca74
fix: address additional CodeRabbit nitpick comments
aknysh 6d19bc7
fix: address latest CodeRabbit review comments
aknysh 2e62a27
fix: use filepath.Join for Windows-compatible path assertion
aknysh 2b59bc1
refactor: rename "two-word command" to "compound subcommand" terminology
aknysh a695c8c
feat: register terraform compound subcommands in Cobra command tree
aknysh 5c97aa0
test: increase coverage for compound subcommand handling
aknysh 46299bb
docs: add dedicated documentation pages for terraform compound subcom…
aknysh 3ca2e94
fix: use platform-appropriate absolute paths in NeedsPathResolution t…
aknysh 3edf956
refactor: extract shared auth manager creation to eliminate duplication
aknysh 3686813
Merge branch 'main' into aknysh/fix-issues-5
aknysh c234a15
Merge branch 'main' into aknysh/fix-issues-5
aknysh 34d5b7a
fix: register Viper defaults for template settings to survive config …
aknysh dd84577
fix: address CodeRabbit review comments
aknysh af93517
fix: address additional CodeRabbit review comments
aknysh 0050089
fix: improve Windows compatibility in test path helpers and assertions
aknysh 6e3ad09
refactor: split compound subcommands and website updates to fix-issues-6
aknysh 6bfa444
test: improve patch coverage for varfile, backend, describe-stacks, a…
aknysh 044ba4f
ci: re-trigger Windows CI to verify flaky test
aknysh 3f37b47
fix: address CodeRabbit review comments on test files
aknysh ef668cd
fix: use forward-slash literals in TestBuildComponentInfo path assert…
aknysh cf28a7d
fix: address CodeRabbit review comments on PR #2035
aknysh a888273
Merge branch 'main' into aknysh/fix-issues-5
aknysh f896f27
updates
aknysh 65f75e3
[autofix.ci] apply automated fixes
autofix-ci[bot] 1027de4
refactor: route terraform shell through ExecuteTerraformShell directly
aknysh d96ea18
Merge branch 'main' into aknysh/fix-issues-5
aknysh 4472f3a
fix: restore files accidentally deleted by split commit and add auth …
aknysh 359729b
Merge branch 'main' into aknysh/fix-issues-5
aknysh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # Regression: Template variables `.atmos_component` and `.atmos_stack` fail in 1.205 | ||
|
|
||
| **Date:** 2026-01-28 | ||
|
|
||
| ## Issue Summary | ||
|
|
||
| Starting in Atmos 1.205, stack manifests that use `{{ .atmos_component }}` or `{{ .atmos_stack }}` | ||
| in non-template files (without `.tmpl` extension) fail with: | ||
|
|
||
| ```text | ||
| Error: failed to execute describe stacks: invalid stack manifest: template: mixins/atmos-pro.yaml:4:21: | ||
| executing "mixins/atmos-pro.yaml" at <.atmos_component>: map has no entry for key "atmos_component" | ||
| ``` | ||
|
|
||
| This worked correctly in Atmos 1.204. | ||
|
|
||
| ## Affected Configuration | ||
|
|
||
| Example `mixins/atmos-pro.yaml`: | ||
|
|
||
| ```yaml | ||
| plan-wf-config: &plan-wf-config | ||
| atmos-terraform-plan.yaml: | ||
| inputs: | ||
| component: "{{ .atmos_component }}" | ||
| stack: "{{ .atmos_stack }}" | ||
|
|
||
| apply-wf-config: &apply-wf-config | ||
| atmos-terraform-apply.yaml: | ||
| inputs: | ||
| component: "{{ .atmos_component }}" | ||
| stack: "{{ .atmos_stack }}" | ||
| github_environment: "{{ .atmos_stack }}" | ||
|
|
||
| settings: | ||
| pro: | ||
| enabled: true | ||
| pull_request: | ||
| opened: | ||
| workflows: *plan-wf-config | ||
| # ... more workflow configs | ||
| ``` | ||
|
|
||
| ## Root Cause Analysis | ||
|
|
||
| The regression was introduced in commit `6ae0a2715` ("Resolve file-scoped locals in stack configurations"). | ||
|
|
||
| ### Previous Behavior (1.204) | ||
|
|
||
| In 1.204, template processing during import was controlled by this condition in `stack_processor_utils.go`: | ||
|
|
||
| ```go | ||
| if !skipTemplatesProcessingInImports && (u.IsTemplateFile(filePath) || len(context) > 0) { | ||
| stackManifestTemplatesProcessed, tmplErr = ProcessTmpl(...) | ||
| } | ||
| ``` | ||
|
|
||
| For non-`.tmpl` files imported without explicit context: | ||
| - `u.IsTemplateFile(filePath)` = false (no `.tmpl` extension) | ||
| - `len(context)` = 0 (no context passed) | ||
| - **Result: Templates NOT processed during import** ✓ | ||
|
|
||
| Templates like `{{ .atmos_component }}` were left unresolved during import and only processed | ||
| later in `describe_stacks.go` when component context was available. | ||
|
|
||
| ### New Behavior (1.205) | ||
|
|
||
| The locals feature added `extractAndAddLocalsToContext()` which extracts `settings`, `vars`, | ||
| `env`, and `locals` from the file itself and adds them to the context: | ||
|
|
||
| ```go | ||
| // New code in extractAndAddLocalsToContext | ||
| if extractResult.settings != nil { | ||
| context[cfg.SettingsSectionName] = extractResult.settings | ||
| } | ||
| if extractResult.vars != nil { | ||
| context[cfg.VarsSectionName] = extractResult.vars | ||
| } | ||
| ``` | ||
|
|
||
| Now for files with a `settings`, `vars`, `env`, or `locals` section: | ||
| - `u.IsTemplateFile(filePath)` = false (no `.tmpl` extension) | ||
| - `len(context)` > 0 (context now contains settings/vars/env/locals from the file!) | ||
| - **Result: Templates ARE processed during import** ✗ | ||
|
|
||
| But `atmos_component` and `atmos_stack` are NOT in the context because they're only set | ||
| later during component processing in `describe_stacks.go`. | ||
|
|
||
| ## Fix | ||
|
|
||
| The fix tracks whether context was "originally provided" vs "populated from file extraction". | ||
| Template processing during import should only occur when: | ||
|
|
||
| 1. The file has a `.tmpl` extension, OR | ||
| 2. Context was explicitly passed from outside (not just extracted from the file itself) | ||
|
|
||
| ### Implementation | ||
|
|
||
| Modified `ProcessBaseStackConfig` in `internal/exec/stack_processor_utils.go`: | ||
|
|
||
| 1. Added tracking of original context before locals extraction: | ||
| ```go | ||
| // Track whether context was originally provided from outside (e.g., via import context). | ||
| originalContextProvided := len(context) > 0 | ||
| ``` | ||
|
|
||
| 2. Changed the template processing condition from: | ||
| ```go | ||
| // OLD (1.205 bug): | ||
| if !skipTemplatesProcessingInImports && (u.IsTemplateFile(filePath) || len(context) > 0) { | ||
| ``` | ||
|
|
||
| To: | ||
| ```go | ||
| // NEW (fixed): | ||
| if !skipTemplatesProcessingInImports && (u.IsTemplateFile(filePath) || originalContextProvided) { | ||
| ``` | ||
|
|
||
| This ensures templates like `{{ .atmos_component }}` are NOT processed during import when the | ||
| only reason context is non-empty is because of file-extracted locals/settings/vars/env. | ||
|
|
||
| ## Steps to Reproduce | ||
|
|
||
| 1. Create `mixins/atmos-pro.yaml` with `settings` section and `{{ .atmos_component }}` templates | ||
| 2. Import this mixin in a stack | ||
| 3. Run `atmos describe stacks` | ||
|
|
||
| ### Expected Result (1.204) | ||
|
|
||
| Stack description succeeds. Template variables are resolved later when component context is available. | ||
|
|
||
| ### Actual Result (1.205) | ||
|
|
||
| ```text | ||
| Error: failed to execute describe stacks: invalid stack manifest: template: mixins/atmos-pro.yaml:4:21: | ||
| executing "mixins/atmos-pro.yaml" at <.atmos_component>: map has no entry for key "atmos_component" | ||
| ``` | ||
|
|
||
| ## Test Case | ||
|
|
||
| See `internal/exec/stack_processor_utils_test.go`: | ||
| - `TestTemplateProcessingWithAtmosComponentInNonTemplateFile` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.