Repository navigation
feat: implement !append YAML function for list concatenation - #1513
Conversation
|
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:
📝 WalkthroughWalkthroughAdds per-field YAML !append handling: YAML loader rewrites tagged sequences into an append wrapper; config preprocessing records wrapped values into Viper; merge pre-processing consumes wrappers to concatenate lists; supporting helpers, tests, docs, fixtures, a CLI test helper, and one exported error alias were added. No public API signatures changed. ChangesYAML processing
Sequence Diagram(s)sequenceDiagram
autonumber
participant YAML as YAML Loader
participant Parse as yaml_utils.processCustomTagsInner
participant Rewrite as rewriteAppendNode
participant Config as process_yaml.go
participant U as utils.WrapWithAppendTag
participant V as Viper
YAML->>Parse: parse nodes
Parse->>Rewrite: detect "!append"
Rewrite->>Rewrite: transform sequence into {"__atmos_append__": sequence}
Parse-->>YAML: rewritten node (tags cleared/preserved as required)
YAML->>Config: processSequenceNode
alt node is append-wrapped
Config->>Config: decode items
Config->>U: WrapWithAppendTag(items)
U-->>Config: {"__atmos_append__": items}
Config->>V: Set(currentPath, wrappedValue)
Config->>Config: Clear node.Tag
else normal flow
Config->>V: Set(path, decoded value)
end
sequenceDiagram
autonumber
participant M as MergeWithOptions
participant P as processAppendTags
participant U as utils.ExtractAppendListValue
participant S as deepMergeNative (merge accumulator)
M->>P: pre-process base map -> preprocessedBase
loop each overlay input
M->>P: pre-process overlay against current accumulator
P->>U: when encountering "__atmos_append__" extract items
alt global strategy append and tag present
P->>S: provide only new items to avoid duplication
else
P->>S: provide concatenated new+existing slice (allocated safely)
end
M->>S: deepMergeNative(preprocessed overlay)
end
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
tests/test-cases/append-function/override-with-append.yaml (1)
1-25: Good coverage of append on both lists of scalars and lists of maps.Consider adding an additional test case (as a separate fixture) that appends an empty list to verify no-ops are handled gracefully.
pkg/config/process_yaml.go (1)
226-249: Append handling is robust and consistent with existing error patterns.
- Decoding each child and wrapping with u.WrapWithAppendTag is clean.
- Tag clearing prevents re-processing.
Minor polish (optional): defensively trim the tag before comparison to be resilient to accidental whitespace.
- if node.Tag == u.AtmosYamlFuncAppend { + if strings.TrimSpace(node.Tag) == u.AtmosYamlFuncAppend {pkg/merge/merge.go (1)
76-133: Append pre-processing logic is clear, recursive, and non-mutating.
- processAppendList preserves order and avoids in-place mutation.
- Recursion via processNestedMap handles deep structures.
Optional: consider a configurable de-duplication step when both global append and tag-based append are active to avoid doubled base elements (keeping default as current behavior for backward compatibility).
pkg/merge/merge_append_test.go (1)
145-173: Global append interaction test is precise.The expected duplication makes the “independent strategies” behavior explicit. Consider adding one more test for a type-mismatch edge case (e.g., base has non-list and override provides append tag) to assert the error or override behavior.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (9)
pkg/config/process_yaml.go(2 hunks)pkg/merge/merge.go(2 hunks)pkg/merge/merge_append_test.go(1 hunks)pkg/utils/yaml_func_append.go(1 hunks)pkg/utils/yaml_func_append_test.go(1 hunks)pkg/utils/yaml_utils.go(1 hunks)tests/test-cases/append-function/base.yaml(1 hunks)tests/test-cases/append-function/expected-result.yaml(1 hunks)tests/test-cases/append-function/override-with-append.yaml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
tests/test-cases/**
📄 CodeRabbit inference engine (CLAUDE.md)
Never modify files under tests/test-cases; these are golden snapshots and must be changed only intentionally with documentation.
Files:
tests/test-cases/append-function/expected-result.yamltests/test-cases/append-function/base.yamltests/test-cases/append-function/override-with-append.yaml
pkg/**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Place business logic in pkg rather than in cmd
Files:
pkg/merge/merge.gopkg/config/process_yaml.gopkg/utils/yaml_utils.gopkg/merge/merge_append_test.gopkg/utils/yaml_func_append_test.gopkg/utils/yaml_func_append.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments
**/*.go: All Go comments must end with periods (enforced by golangci-lint's godot).
Wrap all errors with static errors defined in errors/errors.go; never return dynamic errors directly; use fmt.Errorf with %w and add details after the static error.
Always bind environment variables using viper.BindEnv and provide an ATMOS_ alternative for each external env var.
Use structured logging for system/debug events; logging must not affect execution and should use appropriate levels per docs/logging.md.
Prefer SDKs over shelling out to binaries for cross-platform compatibility; use filepath/os/runtime for portable paths and OS-specific logic.
Files:
pkg/merge/merge.gopkg/config/process_yaml.gopkg/utils/yaml_utils.gopkg/merge/merge_append_test.gopkg/utils/yaml_func_append_test.gopkg/utils/yaml_func_append.go
**/!(*_test).go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Document all exported functions, types, and methods with Go doc comments
Files:
pkg/merge/merge.gopkg/config/process_yaml.gopkg/utils/yaml_utils.gopkg/utils/yaml_func_append.go
pkg/config/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
Use Viper for configuration management with config name "atmos", add config path ".", and AutomaticEnv with ATMOS prefix.
Files:
pkg/config/process_yaml.go
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for multiple scenarios
**/*_test.go: Use table-driven tests for unit tests and focus on pure functions where possible.
Always use t.Skipf with a clear reason when skipping tests; never use t.Skip.
For CLI tests requiring rebuilt binaries, set a package-level skipReason in TestMain and call os.Exit(m.Run()); individual tests must check and t.Skipf if set; never use log.Fatal for missing/stale binaries.
Mirror test file names to their implementation files (e.g., aws_ssm_store_test.go for aws_ssm_store.go) and co-locate tests with implementation.
Files:
pkg/merge/merge_append_test.gopkg/utils/yaml_func_append_test.go
pkg/**/*_test.go
📄 CodeRabbit inference engine (CLAUDE.md)
Place unit tests under pkg/** matching the package they test.
Files:
pkg/merge/merge_append_test.gopkg/utils/yaml_func_append_test.go
🧠 Learnings (6)
📚 Learning: 2025-04-24T01:40:13.576Z
Learnt from: haitham911
PR: cloudposse/atmos#1202
File: pkg/config/process_yaml.go:0-0
Timestamp: 2025-04-24T01:40:13.576Z
Learning: When processing YAML nodes with custom directives in Go using gopkg.in/yaml.v3, setting node.Tag = "" is sufficient to prevent re-processing of the node. It's not necessary to also clear node.Value after updating the configuration store (e.g., Viper), as the original value doesn't affect subsequent operations once the tag is removed.
Applied to files:
pkg/config/process_yaml.go
📚 Learning: 2025-04-24T01:06:15.259Z
Learnt from: haitham911
PR: cloudposse/atmos#1202
File: pkg/config/process_yaml.go:0-0
Timestamp: 2025-04-24T01:06:15.259Z
Learning: When processing YAML structures with gopkg.in/yaml.v3, the Value field of a Node is only meant for scalar values. Complex data types like maps and arrays are represented through child nodes in the YAML tree structure.
Applied to files:
pkg/config/process_yaml.go
📚 Learning: 2025-01-19T22:30:27.600Z
Learnt from: aknysh
PR: cloudposse/atmos#0
File: :0-0
Timestamp: 2025-01-19T22:30:27.600Z
Learning: The Atmos YAML function `!include` allows downloading local or remote files from different sources and assigning their contents to sections in stack manifests. It supports various protocols (file, http, git, s3, etc.) and can filter content using YQ expressions.
Applied to files:
pkg/utils/yaml_utils.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*_test.go : Every new feature must include comprehensive unit tests
Applied to files:
pkg/utils/yaml_func_append_test.go
📚 Learning: 2025-09-25T03:30:16.196Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-25T03:30:16.196Z
Learning: Applies to **/*_test.go : Use table-driven tests for unit tests and focus on pure functions where possible.
Applied to files:
pkg/utils/yaml_func_append_test.go
📚 Learning: 2025-09-25T03:30:16.196Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-25T03:30:16.196Z
Learning: Applies to pkg/**/*_test.go : Place unit tests under pkg/** matching the package they test.
Applied to files:
pkg/utils/yaml_func_append_test.go
🧬 Code graph analysis (5)
pkg/merge/merge.go (1)
pkg/utils/yaml_func_append.go (1)
ExtractAppendListValue(39-48)
pkg/config/process_yaml.go (2)
pkg/utils/yaml_utils.go (1)
AtmosYamlFuncAppend(27-27)pkg/utils/yaml_func_append.go (1)
WrapWithAppendTag(52-56)
pkg/merge/merge_append_test.go (3)
pkg/schema/schema.go (3)
AtmosConfiguration(26-61)Settings(677-681)AtmosSettings(247-267)pkg/merge/merge.go (3)
ListMergeStrategyReplace(14-14)Merge(135-171)ListMergeStrategyAppend(15-15)pkg/utils/yaml_func_append.go (1)
WrapWithAppendTag(52-56)
pkg/utils/yaml_func_append_test.go (1)
pkg/utils/yaml_func_append.go (5)
IsAppendTag(22-24)HasAppendTag(28-36)ExtractAppendListValue(39-48)WrapWithAppendTag(52-56)ProcessAppendTag(12-19)
pkg/utils/yaml_func_append.go (1)
pkg/utils/yaml_utils.go (1)
AtmosYamlFuncAppend(27-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Build (ubuntu-latest, linux)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Run pre-commit hooks
- GitHub Check: Summary
🔇 Additional comments (7)
pkg/utils/yaml_utils.go (1)
27-27: Constant for !append tag added — looks good.The new AtmosYamlFuncAppend constant is concise and aligns with the other tag constants.
tests/test-cases/append-function/base.yaml (1)
1-28: Fixture baseline reads clearly and mirrors real usage.Solid base for demonstrating per-field list concatenation.
pkg/config/process_yaml.go (1)
72-77: Correctly handles tagged sequence nodes.Nice addition to process sequence nodes before walking children. Ensure downstream consumers of Viper keys tolerate bracketed index paths (e.g., key[0]) since those paths are now set for children of sequences.
Would you confirm that no code relies on dot-only key paths and that bracketed paths won’t be read back accidentally as top-level keys?
tests/test-cases/append-function/expected-result.yaml (1)
1-39: Expected result matches the intended semantics.This accurately reflects base + append outcomes for both depends_on and node_groups.
pkg/merge/merge.go (1)
35-37: Pre-merge append processing placed at the right stage.Running processAppendTags before YAML round-trip avoids pointer aliasing issues and preserves intent for mergo options.
pkg/merge/merge_append_test.go (1)
12-143: Comprehensive, table-driven tests for core scenarios.Covers: append to existing, append when missing, replacement without tag, and mixed keys.
pkg/utils/yaml_func_append_test.go (1)
9-176: Good unit coverage on tag detection, extraction, wrapping, and no-op processing.Covers happy paths and negatives with table-driven style using testify. Nicely done.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (76.10%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1513 +/- ##
==========================================
+ Coverage 78.90% 78.92% +0.02%
==========================================
Files 1202 1205 +3
Lines 116155 116265 +110
==========================================
+ Hits 91648 91763 +115
+ Misses 19441 19429 -12
- Partials 5066 5073 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
pkg/utils/yaml_func_append.go(1 hunks)website/docs/functions/yaml/append.mdx(1 hunks)website/docs/functions/yaml/index.mdx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
website/**
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
website/**: Update website documentation in website/ when adding features
Ensure consistency between CLI help text and website documentation
Follow the website's documentation structure and style
Keep website code in website/ and follow its architecture/style; test changes locally
Keep CLI and website documentation in sync; document new features with examples and use cases
Files:
website/docs/functions/yaml/index.mdxwebsite/docs/functions/yaml/append.mdx
pkg/**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Place business logic in pkg rather than in cmd
Files:
pkg/utils/yaml_func_append.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments
**/*.go: All Go comments must end with periods (enforced by golangci-lint's godot).
Wrap all errors with static errors defined in errors/errors.go; never return dynamic errors directly; use fmt.Errorf with %w and add details after the static error.
Always bind environment variables using viper.BindEnv and provide an ATMOS_ alternative for each external env var.
Use structured logging for system/debug events; logging must not affect execution and should use appropriate levels per docs/logging.md.
Prefer SDKs over shelling out to binaries for cross-platform compatibility; use filepath/os/runtime for portable paths and OS-specific logic.
Files:
pkg/utils/yaml_func_append.go
**/!(*_test).go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Document all exported functions, types, and methods with Go doc comments
Files:
pkg/utils/yaml_func_append.go
🧠 Learnings (6)
📚 Learning: 2024-12-01T00:33:20.298Z
Learnt from: aknysh
PR: cloudposse/atmos#810
File: examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml:28-32
Timestamp: 2024-12-01T00:33:20.298Z
Learning: In `examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml`, `!exec atmos terraform output` is used in examples to demonstrate its usage, even though `!terraform.output` is the recommended approach according to the documentation.
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2025-01-19T22:30:27.600Z
Learnt from: aknysh
PR: cloudposse/atmos#0
File: :0-0
Timestamp: 2025-01-19T22:30:27.600Z
Learning: The Atmos YAML function `!env` is used to retrieve environment variables and assign them to sections in stack manifests. It supports both simple types (string, number, boolean) and complex types (JSON-encoded lists, maps, objects).
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2025-01-19T22:30:27.600Z
Learnt from: aknysh
PR: cloudposse/atmos#0
File: :0-0
Timestamp: 2025-01-19T22:30:27.600Z
Learning: The Atmos YAML function `!include` allows downloading local or remote files from different sources and assigning their contents to sections in stack manifests. It supports various protocols (file, http, git, s3, etc.) and can filter content using YQ expressions.
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2024-12-03T04:01:16.446Z
Learnt from: aknysh
PR: cloudposse/atmos#810
File: website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx:0-0
Timestamp: 2024-12-03T04:01:16.446Z
Learning: In the `terraform.output.mdx` documentation file (`website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx`), the cache invalidation and cache scope behavior for the `!terraform.output` function are already described.
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2025-09-25T03:30:16.196Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-25T03:30:16.196Z
Learning: Applies to **/*.go : All Go comments must end with periods (enforced by golangci-lint's godot).
Applied to files:
pkg/utils/yaml_func_append.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
PR: cloudposse/atmos#0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*.go : Document complex logic with inline comments
Applied to files:
pkg/utils/yaml_func_append.go
🧬 Code graph analysis (1)
pkg/utils/yaml_func_append.go (1)
pkg/utils/yaml_utils.go (1)
AtmosYamlFuncAppend(27-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Build (ubuntu-latest, linux)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Run pre-commit hooks
- GitHub Check: Analyze (go)
- GitHub Check: website-deploy-preview
- GitHub Check: Lint (golangci)
- GitHub Check: Summary
🔇 Additional comments (2)
website/docs/functions/yaml/append.mdx (1)
12-52: Docs nail the append narrative.The walkthrough and examples read clean and make the per-field behavior obvious.
website/docs/functions/yaml/index.mdx (1)
46-59: Nice touch integrating the new tag.The blurb slots right in and points folks to the deeper doc.
b3d174c to
01382a3
Compare
|
💥 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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
pkg/merge/merge.go (2)
139-142: Fix invalid use of multiple %w in fmt.Errorf.fmt.Errorf only supports a single %w. Using two is invalid and breaks error wrapping.
Apply:
- return nil, fmt.Errorf("%w: %w", errUtils.ErrMerge, errUtils.ErrAtmosConfigIsNil) + return nil, fmt.Errorf("%w: %v", errUtils.ErrMerge, errUtils.ErrAtmosConfigIsNil)As per coding guidelines.
179-186: Fix invalid use of multiple %w in fmt.Errorf (again).Same issue here.
Apply:
- if atmosConfig == nil { - err := fmt.Errorf("%w: %w", errUtils.ErrMerge, errUtils.ErrAtmosConfigIsNil) + if atmosConfig == nil { + err := fmt.Errorf("%w: %v", errUtils.ErrMerge, errUtils.ErrAtmosConfigIsNil)As per coding guidelines.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (13)
errors/errors.go(1 hunks)pkg/config/process_yaml.go(2 hunks)pkg/merge/merge.go(2 hunks)pkg/merge/merge_append_test.go(1 hunks)pkg/utils/yaml_func_append.go(1 hunks)pkg/utils/yaml_func_append_test.go(1 hunks)pkg/utils/yaml_utils.go(1 hunks)tests/cli_test.go(2 hunks)tests/test-cases/append-function/base.yaml(1 hunks)tests/test-cases/append-function/expected-result.yaml(1 hunks)tests/test-cases/append-function/override-with-append.yaml(1 hunks)website/docs/functions/yaml/append.mdx(1 hunks)website/docs/functions/yaml/index.mdx(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- pkg/utils/yaml_utils.go
- pkg/utils/yaml_func_append_test.go
- pkg/config/process_yaml.go
- pkg/merge/merge_append_test.go
- pkg/utils/yaml_func_append.go
- website/docs/functions/yaml/append.mdx
🧰 Additional context used
📓 Path-based instructions (9)
tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place integration tests and shared test utilities under tests/ with fixtures in tests/test-cases/.
Files:
tests/test-cases/append-function/base.yamltests/cli_test.gotests/test-cases/append-function/expected-result.yamltests/test-cases/append-function/override-with-append.yaml
{tests/test-cases/**,tests/testdata/**}
📄 CodeRabbit inference engine (CLAUDE.md)
Never modify golden snapshot directories tests/test-cases/ or tests/testdata/ unless explicitly instructed.
Files:
tests/test-cases/append-function/base.yamltests/test-cases/append-function/expected-result.yamltests/test-cases/append-function/override-with-append.yaml
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments
**/*.go: All comments must end with periods.
Wrap all returned errors with static errors from errors/errors.go; never return dynamic errors directly.
Use fmt.Errorf with %w to wrap the static error first, then add context details.
Always bind environment variables via viper.BindEnv, providing an ATMOS_ alternative for each external var.
All new configurations must support Go templating using the shared FuncMap(); test template rendering with various contexts.
Prefer SDKs over shelling out to binaries; use standard library for cross-platform behavior (filepath.Join, os.PathSeparator, runtime.GOOS).
For non-standard execution paths, capture telemetry via telemetry.CaptureCmd or telemetry.CaptureCmdString without user data.
Files:
errors/errors.gopkg/merge/merge.gotests/cli_test.go
**/!(*_test).go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Document all exported functions, types, and methods with Go doc comments
Files:
errors/errors.gopkg/merge/merge.go
errors/errors.go
📄 CodeRabbit inference engine (CLAUDE.md)
Define static errors in errors/errors.go (e.g., ErrInvalidComponent, ErrInvalidStack, ErrInvalidConfig).
Files:
errors/errors.go
pkg/**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Place business logic in pkg rather than in cmd
Target >80% coverage for packages, focusing on pkg/ and internal/exec/.
Files:
pkg/merge/merge.go
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for multiple scenarios
**/*_test.go: Use table-driven tests for unit tests where applicable.
Always use t.Skipf() with a reason; do not use t.Skip() or t.Skipf() without explanation.
TestMain must call os.Exit(m.Run()) to propagate test exit code for CLI tests.
Files:
tests/cli_test.go
tests/**/*_test.go
📄 CodeRabbit inference engine (CLAUDE.md)
Use precondition-based skipping helpers from tests/test_preconditions.go for external dependencies (AWS, GitHub, network).
Files:
tests/cli_test.go
website/**
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
website/**: Update website documentation in website/ when adding features
Ensure consistency between CLI help text and website documentation
Follow the website's documentation structure and style
Keep website code in website/ and follow its architecture/style; test changes locally
Keep CLI and website documentation in sync; document new features with examples and use cases
Files:
website/docs/functions/yaml/index.mdx
🧠 Learnings (13)
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Applied to files:
tests/cli_test.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
PR: cloudposse/atmos#1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain XDG compliance implementation is complete with GetXDGCacheDir() and GetXDGTempCacheDir() functions in toolchain/xdg_cache.go, updated installer.go and toolchain_clean.go to use these helpers, and changed cache paths from ~/.cache/tools-cache to ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain when XDG_CACHE_HOME is not set).
Applied to files:
tests/cli_test.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
PR: cloudposse/atmos#1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: The atmos codebase has a custom extension to *testing.T that provides a Chdir method, allowing test functions to call t.Chdir() to change working directories during tests. This is used consistently across test files in the codebase.
Applied to files:
tests/cli_test.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
PR: cloudposse/atmos#1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain has been updated to follow XDG Base Directory Specification with helper functions GetXDGCacheDir() and GetXDGTempCacheDir() in toolchain/xdg_cache.go, using XDG_CACHE_HOME when set and falling back to ~/.cache/atmos-toolchain, making it consistent with atmos core's XDG compliance.
Applied to files:
tests/cli_test.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
PR: cloudposse/atmos#1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: XDG Base Directory Specification compliance implementation for atmos toolchain is complete: created toolchain/xdg_cache.go with GetXDGCacheDir() and GetXDGTempCacheDir() functions, updated toolchain/installer.go and cmd/toolchain_clean.go to use these XDG helpers, and changed all cache paths from hardcoded ~/.cache/tools-cache to XDG-compliant ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback).
Applied to files:
tests/cli_test.go
📚 Learning: 2025-09-26T05:52:03.918Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-26T05:52:03.918Z
Learning: Applies to tests/**/*_test.go : Use precondition-based skipping helpers from tests/test_preconditions.go for external dependencies (AWS, GitHub, network).
Applied to files:
tests/cli_test.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
PR: cloudposse/atmos#1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: Final XDG Base Directory Specification implementation for atmos toolchain is complete and verified: toolchain/xdg_cache.go provides GetXDGCacheDir() and GetXDGTempCacheDir() functions, all hardcoded ~/.cache/tools-cache paths have been replaced with XDG-compliant paths using ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback), and tests have been updated to expect the new path structure.
Applied to files:
tests/cli_test.go
📚 Learning: 2025-09-26T05:52:03.918Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-26T05:52:03.918Z
Learning: Applies to tests/test_preconditions.go : Centralize test precondition helpers in tests/test_preconditions.go.
Applied to files:
tests/cli_test.go
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
PR: cloudposse/atmos#808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.
Applied to files:
tests/cli_test.go
📚 Learning: 2024-12-01T00:33:20.298Z
Learnt from: aknysh
PR: cloudposse/atmos#810
File: examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml:28-32
Timestamp: 2024-12-01T00:33:20.298Z
Learning: In `examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml`, `!exec atmos terraform output` is used in examples to demonstrate its usage, even though `!terraform.output` is the recommended approach according to the documentation.
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2025-01-19T22:30:27.600Z
Learnt from: aknysh
PR: cloudposse/atmos#0
File: :0-0
Timestamp: 2025-01-19T22:30:27.600Z
Learning: The Atmos YAML function `!env` is used to retrieve environment variables and assign them to sections in stack manifests. It supports both simple types (string, number, boolean) and complex types (JSON-encoded lists, maps, objects).
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2025-01-19T22:30:27.600Z
Learnt from: aknysh
PR: cloudposse/atmos#0
File: :0-0
Timestamp: 2025-01-19T22:30:27.600Z
Learning: The Atmos YAML function `!include` allows downloading local or remote files from different sources and assigning their contents to sections in stack manifests. It supports various protocols (file, http, git, s3, etc.) and can filter content using YQ expressions.
Applied to files:
website/docs/functions/yaml/index.mdx
📚 Learning: 2024-12-03T04:01:16.446Z
Learnt from: aknysh
PR: cloudposse/atmos#810
File: website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx:0-0
Timestamp: 2024-12-03T04:01:16.446Z
Learning: In the `terraform.output.mdx` documentation file (`website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx`), the cache invalidation and cache scope behavior for the `!terraform.output` function are already described.
Applied to files:
website/docs/functions/yaml/index.mdx
🧬 Code graph analysis (2)
pkg/merge/merge.go (1)
pkg/utils/yaml_func_append.go (1)
ExtractAppendListValue(39-48)
tests/cli_test.go (1)
pkg/logger/log.go (1)
Info(34-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Run pre-commit hooks
- GitHub Check: website-deploy-preview
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Summary
🔇 Additional comments (2)
tests/test-cases/append-function/override-with-append.yaml (1)
1-25: LGTM.Good coverage of nested append scenarios (eks node_groups, settings.depends_on, and rds depends_on). This aligns with the intended per-field opt-in behavior.
pkg/merge/merge.go (1)
134-171: Public signature unchanged vs summary.The AI summary mentions a public signature change dropping the inputs parameter from Merge, but this file still requires inputs []map[string]any. Confirm intended surface.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
tests/cli_test.go (1)
518-518: Fix skipReason shadowing so tests actually skip.Line 518 uses
:=which shadows the package-levelskipReason, preventing tests from skipping when they should. Use=with a local declaration forbinaryPath.Apply this diff:
// Check for the atmos binary - binaryPath, skipReason := validateAtmosBinary(repoRoot) + var binaryPath string + binaryPath, skipReason = validateAtmosBinary(repoRoot)pkg/merge/merge.go (2)
39-40: Prevent double-append under append list merge strategy.When
appendSlice=true(global append strategy),processAppendListexpands the list to include existing items, thenmergo.WithAppendSliceappends again, causing duplication. Pass theappendSliceflag through and return only new items when true.Also, inline comments at lines 94, 99, 104, and 117 are missing periods per coding guidelines.
Apply this diff:
- // Process !append tagged lists before merging - current = processAppendTags(current, merged) + // Process !append tagged lists before merging. + current = processAppendTags(current, merged, appendSlice) @@ -// processAppendTags handles special !append tagged lists during merging. -// It processes any values wrapped with __atmos_append__ metadata and appends them to existing lists. -func processAppendTags(current map[string]any, merged map[string]any) map[string]any { +// processAppendTags handles special !append tagged lists during merging. +// It processes any values wrapped with __atmos_append__ metadata and appends them to existing lists. +// When appendNewOnly is true (global append strategy), it returns only the new items so that mergo.WithAppendSlice performs the append without duplication. +func processAppendTags(current map[string]any, merged map[string]any, appendNewOnly bool) map[string]any { result := make(map[string]any) for key, value := range current { - result[key] = processValue(key, value, merged) + result[key] = processValue(key, value, merged, appendNewOnly) } return result } // processValue processes a single value for append tags. -func processValue(key string, value any, merged map[string]any) any { - // Check if this is an append-tagged list +func processValue(key string, value any, merged map[string]any, appendNewOnly bool) any { + // Check if this is an append-tagged list. if list, isAppend := u.ExtractAppendListValue(value); isAppend { - return processAppendList(key, list, merged) + return processAppendList(key, list, merged, appendNewOnly) } - // Check if this is a nested map + // Check if this is a nested map. if nestedMap, ok := value.(map[string]any); ok { - return processNestedMap(key, nestedMap, merged) + return processNestedMap(key, nestedMap, merged, appendNewOnly) } - // Regular value, pass through + // Regular value, pass through. return value } -// processAppendList handles appending a list to existing values. -func processAppendList(key string, list []any, merged map[string]any) []any { +// processAppendList handles appending a list to existing values. +// If appendNewOnly is true, return only the new items so mergo.WithAppendSlice can append them to the existing list without duplication. +func processAppendList(key string, list []any, merged map[string]any, appendNewOnly bool) []any { + if appendNewOnly { + return list + } var existingList []any if existingValue, exists := merged[key]; exists { if el, ok := existingValue.([]any); ok { existingList = el } } - // Create a new slice to avoid modifying the original + // Create a new slice to avoid modifying the original. result := make([]any, len(existingList), len(existingList)+len(list)) copy(result, existingList) result = append(result, list...) return result }Based on coding guidelines.
Also applies to: 80-122
124-136: Update processNestedMap to propagate appendNewOnly flag.The recursive call needs to pass through the
appendNewOnlyflag for consistency with the rest of the append tag processing chain.Apply this diff:
// processNestedMap recursively processes nested maps for append tags. -func processNestedMap(key string, nestedMap map[string]any, merged map[string]any) map[string]any { +func processNestedMap(key string, nestedMap map[string]any, merged map[string]any, appendNewOnly bool) map[string]any { var mergedNested map[string]any if existingNested, exists := merged[key]; exists { if mn, ok := existingNested.(map[string]any); ok { mergedNested = mn } } if mergedNested == nil { mergedNested = make(map[string]any) } - return processAppendTags(nestedMap, mergedNested) + return processAppendTags(nestedMap, mergedNested, appendNewOnly) }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
errors/errors.go(1 hunks)pkg/config/process_yaml.go(2 hunks)pkg/merge/merge.go(2 hunks)pkg/utils/yaml_utils.go(1 hunks)tests/cli_test.go(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/utils/yaml_utils.go
- errors/errors.go
🧰 Additional context used
📓 Path-based instructions (8)
pkg/**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Place business logic in pkg rather than in cmd
Files:
pkg/config/process_yaml.gopkg/merge/merge.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments
**/*.go: All Go comments must end with periods. Enforced by golangci-lint's godot.
Organize imports into three groups (stdlib, third-party, Atmos) separated by blank lines; sort alphabetically within each group; maintain existing aliases.
Add defer perf.Track(...) to all public functions and critical private functions, with a blank line after the call and package-prefixed name (e.g., "exec.ProcessComponent"). Use atmosConfig if available, otherwise nil.
Wrap all errors using static errors defined in errors/errors.go; never return dynamic errors directly.
Use the error wrapping pattern: fmt.Errorf("%w: details", errUtils.ErrStaticError, ...) with %w to preserve error chains and add context after the static error.
Bind environment variables with viper.BindEnv() and provide ATMOS_ alternatives for every env var (e.g., viper.BindEnv("ATMOS_GITHUB_TOKEN", "GITHUB_TOKEN")).
Ensure cross-platform compatibility: prefer SDKs over invoking binaries, use filepath.Join, os.PathSeparator/PathListSeparator, and runtime.GOOS when necessary.
Files:
pkg/config/process_yaml.gotests/cli_test.gopkg/merge/merge.go
**/!(*_test).go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Document all exported functions, types, and methods with Go doc comments
Files:
pkg/config/process_yaml.gopkg/merge/merge.go
{cmd,internal,pkg}/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
{cmd,internal,pkg}/**/*.go: Do not use logging for UI output. Send prompts/status/progress and actionable errors to stderr; send data/results to stdout; keep logging for system/debug with structured fields.
Most text UI must go to stderr; only data/results go to stdout. Prefer utils.PrintfMessageToTUI for UI messages.
For non-standard execution paths, capture telemetry using telemetry.CaptureCmd(...) or telemetry.CaptureCmdString(...); never capture user data.
Files:
pkg/config/process_yaml.gopkg/merge/merge.go
{internal/exec,pkg}/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
All new configs must support Go templating using FuncMap() from internal/exec/template_funcs.go.
Files:
pkg/config/process_yaml.gopkg/merge/merge.go
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for multiple scenarios
**/*_test.go: Use table-driven tests for unit tests.
Always use t.Skipf(...) with a clear reason when skipping tests; do not use t.Skip().
TestMain must call os.Exit(m.Run()) to propagate the test exit code for CLI tests.
Co-locate test files with implementation (use _test.go alongside .go files) and maintain naming symmetry with implementation files.
Files:
tests/cli_test.go
tests/**/*_test.go
📄 CodeRabbit inference engine (CLAUDE.md)
Place integration tests under tests/ with fixtures in tests/test-cases/.
Files:
tests/cli_test.go
tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place shared test utilities for integration tests in the tests/ directory.
Files:
tests/cli_test.go
🧠 Learnings (2)
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Applied to files:
tests/cli_test.go
📚 Learning: 2025-10-02T20:13:55.579Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-02T20:13:55.579Z
Learning: Applies to **/*_test.go : Always use t.Skipf(...) with a clear reason when skipping tests; do not use t.Skip().
Applied to files:
tests/cli_test.go
🧬 Code graph analysis (3)
pkg/config/process_yaml.go (3)
pkg/utils/yaml_utils.go (1)
AtmosYamlFuncAppend(28-28)pkg/logger/log.go (1)
Debug(24-26)pkg/utils/yaml_func_append.go (1)
WrapWithAppendTag(52-56)
tests/cli_test.go (1)
pkg/logger/log.go (1)
Info(34-36)
pkg/merge/merge.go (1)
pkg/utils/yaml_func_append.go (1)
ExtractAppendListValue(39-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Analyze (go)
- GitHub Check: Lint (golangci)
- GitHub Check: Run pre-commit hooks
- GitHub Check: website-deploy-preview
- GitHub Check: Summary
🔇 Additional comments (3)
pkg/config/process_yaml.go (2)
216-222: LGTM!Clean delegation pattern for handling tagged sequence nodes. The switch-like structure makes it easy to add more tag handlers in the future.
224-250: LGTM!The implementation correctly decodes list items, wraps them with append metadata, and stores the result in Viper. Error handling properly wraps errors with context, and the tag is cleared to prevent re-processing.
tests/cli_test.go (1)
484-498: LGTM!The helper provides clean binary validation logic with appropriate skip reasons for test flow control.
|
Warning This PR exceeds the recommended limit of 1,000 lines.Large PRs are difficult to review and may be rejected due to their size. Please verify that this PR does not address multiple issues. |
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
|
Warning Changelog Entry RequiredThis PR is labeled Action needed: Add a new blog post in Example filename: Alternatively: If this change doesn't require a changelog entry, remove the |
The !append YAML function only worked in atmos.yaml (via handleAppend in
process_yaml.go). In stack manifests — its documented use case — the tag was
silently dropped during unmarshaling, so the merge replaced the list instead of
appending it.
Fix: handle !append in the stack node-walker (pkg/utils/yaml_utils.go).
- hasCustomTags now recognizes !append so the early-exit optimization does not
skip trees that only contain !append.
- processCustomTagsInner rewrites an !append-tagged sequence into the
map[string]any{__atmos_append__: <list>} wrapper that pkg/merge consumes,
processing any custom tags inside the list items first. Non-sequence !append
is a graceful no-op (tag cleared).
- Extracted the wrapper key into the shared AppendTagMetadataKey constant
(removing the duplicated "__atmos_append__" literal).
Also switch yaml_func_append.go from a direct charmbracelet/log import to the
pkg/logger alias used everywhere else in the package.
Tests:
- pkg/utils/yaml_func_append_stack_test.go: stack-path rewrite (sequence, nested,
list-of-maps, inner custom tags, non-sequence no-op, hasCustomTags detection).
- pkg/merge/merge_append_test.go: chained 3-input, base-input, list-of-maps,
type-mismatch fallback, new-key, immutability, and a full end-to-end test that
unmarshals two stack manifests and merges them.
- pkg/config/process_yaml_append_test.go: handleAppend (was 0% covered).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Changelog/PRD/roadmap for the !append YAML function (required for the `minor` label): - Add docs/prd/yaml-append-function.md documenting the design, including the dual-path wrapping (atmos.yaml + stack manifests) and merge integration. - Add the announcement blog post (slug: append-yaml-function). - Flip the extensibility roadmap milestone to shipped (q2-2026), link the changelog and docs, and bump initiative progress 90 -> 93. Remove dead exported helpers ProcessAppendTag and IsAppendTag (no production callers; ProcessAppendTag was a logging no-op) and their tests. The feature uses WrapWithAppendTag/ExtractAppendListValue (and HasAppendTag as the public predicate). The functions/yaml/append.mdx reference page was reviewed and is correct: !append yields the same appended result under all three global list_merge_strategy values (replace, append, merge), matching its documented table. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
CodeRabbit (@coderabbitai) full review please |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== pkg/utils/yaml_func_append.go ==="
cat pkg/utils/yaml_func_append.go
echo ""
echo "=== pkg/utils/yaml_func_append_test.go ==="
cat pkg/utils/yaml_func_append_test.go
echo ""
echo "=== pkg/utils/yaml_utils.go (relevant section) ==="
rg -n "AtmosYamlFunc|!append|append" pkg/utils/yaml_utils.go -C2
echo ""
echo "=== pkg/merge/merge.go ==="
cat pkg/merge/merge.go
echo ""
echo "=== pkg/merge/merge_append_test.go ==="
cat pkg/merge/merge_append_test.go
echo ""
echo "=== pkg/config/process_yaml.go ==="
cat pkg/config/process_yaml.go
echo ""
echo "=== tests/test-cases/append-function/base.yaml ==="
cat tests/test-cases/append-function/base.yaml
echo ""
echo "=== tests/test-cases/append-function/override-with-append.yaml ==="
cat tests/test-cases/append-function/override-with-append.yaml
echo ""
echo "=== tests/test-cases/append-function/expected-result.yaml ==="
cat tests/test-cases/append-function/expected-result.yaml
echo ""
echo "=== website/docs/functions/yaml/append.mdx ==="
cat website/docs/functions/yaml/append.mdx
echo ""
echo "=== website/docs/functions/yaml/index.mdx (changed sections) ==="
cat website/docs/functions/yaml/index.mdx
echo ""
echo "=== errors/errors.go (ErrRefusingToDeleteSymlink area) ==="
rg -n "ErrRefusingToDeleteSymlink|symlink|Symlink" errors/errors.go -C3Length of output: 83355 🏁 Script executed: #!/bin/bash
echo "=== handleAppend function ==="
rg -n "func handleAppend" --type go -A 30
echo ""
echo "=== MergeWithProvenance - does it handle append tags? ==="
rg -n "processAppendTags\|MergeWithProvenance\|appendTag" pkg/merge/ -A 3
echo ""
echo "=== AtmosYamlFuncAppend NOT in AtmosYamlTags slice? ==="
rg -n "AtmosYamlFuncAppend\|AtmosYamlTags\|atmosYamlTagsMap" pkg/utils/yaml_utils.go
echo ""
echo "=== Check AtmosYamlFuncAppend in containsCustomTags or hasCustomTag ==="
rg -n "AtmosYamlFuncAppend" --type go
echo ""
echo "=== rewriteAppendNode function ==="
rg -n "func rewriteAppendNode" --type go -A 40
echo ""
echo "=== processCustomTagsInner or stack manifest append processing ==="
rg -n "rewriteAppendNode\|AtmosYamlFuncAppend\|!append" --type go -C3
echo ""
echo "=== Check MergeWithProvenance function for append handling ==="
rg -n "func MergeWithProvenance" --type go -A 80 | head -100
echo ""
echo "=== Does processAppendTags get called from MergeWithProvenance? ==="
fd "provenance" --type fLength of output: 12806
Review:
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
pkg/utils/yaml_utils.go (1)
62-89:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUnify
!appendwith the canonical custom-tag registries.
AtmosYamlFuncAppendis defined, but it is not registered inAtmosYamlTags/atmosYamlTagsMap. The current behavior depends on ad-hoc checks inprocessCustomTagsInnerandhasCustomTags, which creates two sources of truth and makes future tag-walk paths easy to miss.Suggested patch.
var ( AtmosYamlTags = []string{ AtmosYamlFuncExec, AtmosYamlFuncStore, AtmosYamlFuncStoreGet, AtmosYamlFuncTemplate, AtmosYamlFuncTerraformOutput, AtmosYamlFuncTerraformState, AtmosYamlFuncEnv, AtmosYamlFuncGitRoot, AtmosYamlFuncGitRootAlias, AtmosYamlFuncGitSha, AtmosYamlFuncGitBranch, AtmosYamlFuncGitRef, AtmosYamlFuncGitRepository, AtmosYamlFuncGitOwner, AtmosYamlFuncGitName, AtmosYamlFuncGitHost, AtmosYamlFuncGitUrl, + AtmosYamlFuncAppend, AtmosYamlFuncCwd, AtmosYamlFuncUnset, AtmosYamlFuncRandom, AtmosYamlFuncLiteral, AtmosYamlFuncAwsAccountID, AtmosYamlFuncAwsCallerIdentityArn, AtmosYamlFuncAwsCallerIdentityUserID, AtmosYamlFuncAwsRegion, AtmosYamlFuncAwsOrganizationID, } @@ atmosYamlTagsMap = map[string]bool{ AtmosYamlFuncExec: true, AtmosYamlFuncStore: true, AtmosYamlFuncStoreGet: true, AtmosYamlFuncTemplate: true, AtmosYamlFuncTerraformOutput: true, AtmosYamlFuncTerraformState: true, AtmosYamlFuncEnv: true, AtmosYamlFuncGitRoot: true, AtmosYamlFuncGitRootAlias: true, AtmosYamlFuncGitSha: true, AtmosYamlFuncGitBranch: true, AtmosYamlFuncGitRef: true, AtmosYamlFuncGitRepository: true, AtmosYamlFuncGitOwner: true, AtmosYamlFuncGitName: true, AtmosYamlFuncGitHost: true, AtmosYamlFuncGitUrl: true, + AtmosYamlFuncAppend: true, AtmosYamlFuncCwd: true, AtmosYamlFuncUnset: true, AtmosYamlFuncRandom: true, AtmosYamlFuncLiteral: true, AtmosYamlFuncAwsAccountID: true, AtmosYamlFuncAwsCallerIdentityArn: true, AtmosYamlFuncAwsCallerIdentityUserID: true, AtmosYamlFuncAwsRegion: true, AtmosYamlFuncAwsOrganizationID: true, } @@ - if atmosYamlTagsMap[tag] || tag == AtmosYamlFuncInclude || tag == AtmosYamlFuncIncludeRaw || tag == AtmosYamlFuncAppend { + if atmosYamlTagsMap[tag] || tag == AtmosYamlFuncInclude || tag == AtmosYamlFuncIncludeRaw { return true }Also applies to: 94-121, 991-991
🤖 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/utils/yaml_utils.go` around lines 62 - 89, AtmosYamlFuncAppend (the `!append` tag) is defined but not included in the canonical tag registries, causing ad‑hoc checks in processCustomTagsInner and hasCustomTags; add AtmosYamlFuncAppend to the AtmosYamlTags slice and ensure it's present in atmosYamlTagsMap initialization so all tag-walking uses the single source of truth, then remove the special-case branches in processCustomTagsInner and hasCustomTags that treated `!append` separately and update any tests to expect `!append` to be detected via the unified registry (use the symbols AtmosYamlFuncAppend, AtmosYamlTags, atmosYamlTagsMap, processCustomTagsInner, hasCustomTags to locate and fix the code).pkg/merge/merge.go (1)
346-349:⚠️ Potential issue | 🟠 Major | ⚡ Quick winResolve
!appendwrappers on the single-input fast path.When there is exactly one non-empty input, the function returns
DeepCopyMapdirectly and skipsprocessAppendTags, so a lone!appendvalue can remain as wrapper metadata instead of resolving to a plain list.💡 Suggested fix
// Fast-path: only one non-empty input, return a deep copy to maintain immutability. if len(nonEmptyInputs) == 1 { - return DeepCopyMap(nonEmptyInputs[0]) + copied, err := DeepCopyMap(nonEmptyInputs[0]) + if err != nil { + return nil, fmt.Errorf("%w: failed to deep copy map: %w", errUtils.ErrMerge, err) + } + return processAppendTags(copied, map[string]any{}, appendSlice), nil }Also applies to: 364-367
🤖 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/merge/merge.go` around lines 346 - 349, The fast-path that returns DeepCopyMap(nonEmptyInputs[0]) skips resolving any !append wrappers; instead, make a deep copy then run processAppendTags on that copy before returning (e.g., assign copied := DeepCopyMap(nonEmptyInputs[0]); processAppendTags(copied); return copied). Apply the same fix to the other identical fast-path branch that currently returns DeepCopyMap directly so lone !append metadata is always resolved.
🤖 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 `@pkg/config/process_yaml_append.go`:
- Around line 20-27: The loop currently decodes each child node directly
(child.Decode) which bypasses nested custom-tag processing and causes items like
"- !env SOME_VAR" inside !append to fail; change the logic to first run each
child through the shared YAML tag/sequence processing path (the same function
used elsewhere to handle custom tags and sequences) before decoding/collecting
into list, so that nested tags are resolved consistently; ensure errors still
wrap with ErrExecuteYamlFunctions on failure and update the code that appends
into list to use the post-processed value; add a regression test in
pkg/config/process_yaml_append_test.go that verifies !append with at least one
nested custom tag item is handled correctly.
In `@pkg/merge/merge_append_test.go`:
- Around line 278-297: TestMergeAppend_DoesNotMutateInputs only checks
result→src isolation; add the missing src→result check by mutating the source
inputs after the Merge call and asserting the computed result remains unchanged.
Specifically, after calling Merge and the existing result mutation check, change
base["items"] and overlayList (e.g., replace or append elements) and then assert
result["items"] still equals []any{"a","b"}; keep using the same
TestMergeAppend_DoesNotMutateInputs, variables (base, overlayList, result) and
Merge/u.WrapWithAppendTag symbols so the new assertions verify src→result
isolation.
In `@tests/cli_test.go`:
- Around line 752-761: The test suite currently uses validateAtmosBinary which
sets skipReason from exec.LookPath("atmos") and then gates all CLI tests;
instead make the PATH lookup only affect tests that truly require the external
installed binary and let tests that use the in-repo AtmosRunner run normally.
Modify the logic around validateAtmosBinary/skipReason so AtmosRunner (the
in-tree runner used to build and run atmos commands) is preferred: if
AtmosRunner is available use that and do not set skipReason; only set skipReason
when a specific test explicitly requires the external PATH binary (referencing
validateAtmosBinary, binaryPath, skipReason, and AtmosRunner to locate the code
to change).
---
Outside diff comments:
In `@pkg/merge/merge.go`:
- Around line 346-349: The fast-path that returns DeepCopyMap(nonEmptyInputs[0])
skips resolving any !append wrappers; instead, make a deep copy then run
processAppendTags on that copy before returning (e.g., assign copied :=
DeepCopyMap(nonEmptyInputs[0]); processAppendTags(copied); return copied). Apply
the same fix to the other identical fast-path branch that currently returns
DeepCopyMap directly so lone !append metadata is always resolved.
In `@pkg/utils/yaml_utils.go`:
- Around line 62-89: AtmosYamlFuncAppend (the `!append` tag) is defined but not
included in the canonical tag registries, causing ad‑hoc checks in
processCustomTagsInner and hasCustomTags; add AtmosYamlFuncAppend to the
AtmosYamlTags slice and ensure it's present in atmosYamlTagsMap initialization
so all tag-walking uses the single source of truth, then remove the special-case
branches in processCustomTagsInner and hasCustomTags that treated `!append`
separately and update any tests to expect `!append` to be detected via the
unified registry (use the symbols AtmosYamlFuncAppend, AtmosYamlTags,
atmosYamlTagsMap, processCustomTagsInner, hasCustomTags to locate and fix the
code).
🪄 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: 3d16d82c-3e6d-43a1-a6ba-2d7e38fb2ecc
📒 Files selected for processing (21)
docs/prd/yaml-append-function.mderrors/errors.gopkg/config/process_yaml.gopkg/config/process_yaml_append.gopkg/config/process_yaml_append_test.gopkg/config/process_yaml_git.gopkg/merge/merge.gopkg/merge/merge_append_test.gopkg/utils/yaml_func_append.gopkg/utils/yaml_func_append_stack_test.gopkg/utils/yaml_func_append_test.gopkg/utils/yaml_utils.gotests/cli_test.gotests/test-cases/append-function/base.yamltests/test-cases/append-function/expected-result.yamltests/test-cases/append-function/override-with-append.yamlwebsite/blog/2026-06-06-append-yaml-function.mdxwebsite/docs/functions/yaml/append.mdxwebsite/docs/functions/yaml/index.mdxwebsite/package.jsonwebsite/src/data/roadmap.js
- Register !append in AtmosYamlTags and atmosYamlTagsMap so it is no longer invisible to code that consults the canonical tag lists; the explicit rewrite branch in processCustomTagsInner still runs first, and the now-redundant manual !append check in hasCustomTags is dropped. Updated the tag-count test. - handleAppend (atmos.yaml path) now resolves custom scalar tags inside an !append list via processScalarNodeValue (e.g. !env/!exec/!cwd), matching the stack-manifest path instead of leaving them unevaluated. Added a test. - merge.processAppendList: guard the capacity computation before allocation (newLen > cap || existingLen > cap-newLen) and compute totalLen after the guard, resolving the CodeQL overflow finding without behavior change. - Fix the append-function fixture: stack imports use `import:` (singular), not `imports:` (which the parser silently ignores). - Add the missing trailing newline to expected-result.yaml. Note: the review's doc-typo comment was inverted — website/docs/functions/yaml/ append.mdx correctly uses `import:`; the actual bug was in the fixture (fixed above). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
MergeWithOptions returns DeepCopyMap(inputs[0]) directly when there is exactly one non-empty input, which skipped processAppendTags. A lone !append value (single contributing layer) therefore leaked the __atmos_append__ wrapper into the result instead of resolving to a plain list. Resolve append tags against an empty accumulator on this fast path too. Added a regression test. Note: the review's "register !append in AtmosYamlTags/atmosYamlTagsMap" comment was already addressed in the previous commit (4255384). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- pkg/config/process_yaml_append.go: handleAppend resolves custom Atmos tags
nested inside map/sub-list items of an !append list (not just top-level
scalars) via a side-effect-free recursive resolver, matching the stack path.
Avoids processSequenceElement, which would leak indexed keys (path[0], ...)
because an !append value is stored as a wrapper map, not an array.
- pkg/config/process_yaml_append_test.go: add regression tests for an !env
scalar item and an !env nested inside a map item (asserting resolution and
that no indexed keys leak into Viper).
- pkg/merge/merge_append_test.go: TestMergeAppend_DoesNotMutateInputs now also
verifies src->result isolation (mutate a source list after merge, assert the
result is unaffected), per the aliasing-test guideline.
- tests/cli_test.go: the binary check no longer sets skipReason from
exec.LookPath("atmos"). CLI tests run via AtmosRunner (built from source), so a
missing/external PATH binary must not skip the whole suite; it is now
informational only, restoring main's non-gating behavior.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…eQL) The previous maxSliceCapacity-based guard did not satisfy CodeQL's overflow analysis. Guard the existingLen+newLen computation with math.MaxInt (compute totalLen only after proving newLen <= MaxInt-existingLen) so the make() cannot overflow and the check is independent of the arbitrary cap. maxSliceCapacity is retained as a separate sanity cap against absurdly large allocations. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.221.0-rc.7. |
|
These changes were released in v1.221.0. |
what
!appendYAML function that allows fine-grained control over list merging behavior in Atmos stack configurations!appendwill be concatenated with base values instead of replacedwhy
depends_onwhere appending is often the desired behavior rather than replacement!appendtag provides opt-in, per-field control that works alongside the globallist_merge_strategysettingKey Features
!appenduse append mode!appendtag works independently of the globallist_merge_strategysettingExample Usage
Testing
references
!appendYAML functionappend-yaml-function; roadmap milestone updated (Extensibility initiative)🤖 Generated with Claude Code
Summary by CodeRabbit