Conversation
…} in non-.tmpl files
Starting in Atmos 1.205, stack manifests using {{ .atmos_component }} or
{{ .atmos_stack }} in non-template files fail during import with:
"map has no entry for key atmos_component"
The locals feature inadvertently triggered template processing for imported
files by populating the template context with settings/vars/env, making
len(context) > 0. Templates like {{ .atmos_component }} then failed because
component context isn't available at import time.
Fix: Track whether context was originally provided externally vs extracted
from the file itself. When template processing fails and only file-extracted
context is available, gracefully fall back to raw content — preserving
templates for later resolution in ProcessStacks when full component context
is available.
Also adds processTemplatesInSection() to resolve {{ .locals.X }} references
in individual sections (settings, vars, env) without processing the whole
file, and persists resolved sections back into stackConfigMap.
Additional fixes included:
- Skip .terraform dirs in describe-affected test copies (dangling symlinks)
- Add --verify=false to helm plugin install in Dockerfile (Helm 4 compat)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
📝 WalkthroughWalkthroughAdds YAML-aware template processing for stack-level sections (locals, settings, vars, env): introduces an unexported helper to render templates inside sections, changes locals key to cfg.LocalsSectionName, defers import-time template evaluation when no external context is provided, persists resolved sections into stackConfigMap, adds tests and fixtures, and tweaks Dockerfile helm-diff install. Changes
Sequence Diagram(s)(Skipped — internal template-processing changes do not introduce a new multi-actor runtime flow requiring a sequence diagram.) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
|
@coderabbitai full review please |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2053 +/- ##
==========================================
+ Coverage 75.65% 75.69% +0.04%
==========================================
Files 793 793
Lines 73892 73953 +61
==========================================
+ Hits 55901 55979 +78
+ Misses 14498 14479 -19
- Partials 3493 3495 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
🧠 Learnings used✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThis PR addresses a regression where settings could not reference locals in version 1.205. It introduces deferred, section-aware template processing for locals, settings, vars, and env with an originalContextProvided flag to distinguish import-time processing from component-specific context. A regression test validates that templates in settings can safely reference locals. Changes
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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: 1
🤖 Fix all issues with AI agents
In `@internal/exec/stack_processor_utils.go`:
- Around line 247-284: The section template contexts currently use only locals
(localsOnlyContext / varsContext / envContext) which ignores any external import
context present in the surrounding `context`, causing templates like `{{
.settings.foo }}` to resolve incorrectly; update the code that builds the
context for processTemplatesInSection (for settings, vars, and env) to start by
copying the existing `context` map, then set/override the entries for
cfg.LocalsSectionName, cfg.SettingsSectionName and cfg.VarsSectionName as needed
before calling processTemplatesInSection so that explicit import/component
context already present in `context` is honored (refer to
processTemplatesInSection, cfg.SettingsSectionName, cfg.VarsSectionName,
cfg.LocalsSectionName, and extractResult.settings/vars/env to locate the spots
to change).
🧹 Nitpick comments (1)
internal/exec/stack_processor_utils_test.go (1)
1975-2061: Solid regression test.Good coverage of the Atmos Pro template regression. The test:
- Clearly documents the 1.204 vs 1.205 behavior difference
- Uses
filepath.Joinfor cross-platform paths- Validates both success and template preservation
One minor note: the assertion on line 2059 checks
Contains(componentInput, "atmos_component")which works, but checking for the exact template string"{{ .atmos_component }}"would be more precise.Optional: More precise assertion
- assert.Contains(t, componentInput, "atmos_component", - "Template {{ .atmos_component }} should be preserved during import, not processed") + assert.Equal(t, "{{ .atmos_component }}", componentInput, + "Template {{ .atmos_component }} should be preserved during import, not processed")
|
🧠 Learnings used✅ Actions performedFull review triggered. |
…nd improve test precision - Seed section contexts (settings/vars/env) with external import context so templates referencing import-provided values resolve during section processing, not just during full-file processing - Change assert.Contains to assert.Equal for template preservation assertions to verify exact template strings are preserved verbatim - Add TestExtractAndAddLocalsToContext_ExternalContext with 3 subtests covering external context resolution, cross-section propagation, and graceful fallback when context is insufficient Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
These changes were released in v1.205.1. |
what
{{ .atmos_component }}and{{ .atmos_stack }}templates in non-.tmplfiles fail during import with:map has no entry for key "atmos_component"processTemplatesInSection()helper to resolve{{ .locals.X }}in individual sections (settings, vars, env) without triggering full-file template processing.terraformdirectories in describe-affected test copies to avoid dangling symlink failures--verify=falsetohelm plugin installin Dockerfile for Helm 4 compatibilitywhy
Atmos Pro template regression (Issue #2032)
The locals feature (PR #1994) inadvertently triggered template processing for imported non-
.tmplfiles.extractAndAddLocalsToContext()populated the template context with settings/vars/env from the file, makinglen(context) > 0, which triggered the template processing guard. Templates like{{ .atmos_component }}then failed because component context isn't available at import time.Fix: Track whether context was originally provided externally (
originalContextProvided) vs extracted from the file itself. When template processing fails and only file-extracted context is available, gracefully fall back to raw content — preserving templates like{{ .atmos_component }}for later resolution inProcessStackswhen the full component context is available.Additionally,
extractAndAddLocalsToContext()now processes templates in individual sections (settings → vars → env) using a pipeline with resolved locals context. This enables bidirectional references between locals and settings while avoiding premature processing of component-scoped templates.Dangling
.terraformsymlinks in describe-affected testsTestDescribeAffectedWith*tests failed locally due to a dangling symlink inexamples/secrets-masking/.terraform/providers/left by a previous test run. Added.terraformto the copy skip filter alongside the existingnode_modulesskip.Helm plugin install in Dockerfile
Helm 4 requires
--verify=falsebecause helm-diff does not ship.provsignature files.references
Summary by CodeRabbit
Bug Fixes
New Features
New Tests
Chores