Skip to content

feat: implement !append YAML function for list concatenation - #1513

Merged
Andriy Knysh (aknysh) merged 16 commits into
mainfrom
feature/dev-2980-implement-append-function
Jun 9, 2026
Merged

Andriy Knysh (aknysh) merged 16 commits into
mainfrom
feature/dev-2980-implement-append-function

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Sep 25, 2025 •

Copy link
Copy Markdown
Member

what

  • Implements the !append YAML function that allows fine-grained control over list merging behavior in Atmos stack configurations
  • Lists tagged with !append will be concatenated with base values instead of replaced
  • Adds comprehensive unit tests and integration test fixtures

why

  • Resolves the ongoing challenge of needing to concatenate lists on a case-by-case basis
  • Currently, users have to fall back to using maps instead of lists when they need append behavior
  • This is particularly important for fields like depends_on where appending is often the desired behavior rather than replacement
  • The !append tag provides opt-in, per-field control that works alongside the global list_merge_strategy setting

Key Features

  • Opt-in behavior: Only lists explicitly tagged with !append use append mode
  • Works alongside global settings: The !append tag works independently of the global list_merge_strategy setting
  • Nested support: Works with deeply nested configurations
  • Backward compatible: No impact on existing configurations without the tag

Example Usage

# base.yaml
components:
  terraform:
    eks:
      settings:
        depends_on:
          - vpc
          - iam-role

# override.yaml
components:
  terraform:
    eks:
      settings:
        depends_on: !append  # This tag indicates append mode
          - rds
          - elasticache
          
# Result: depends_on = [vpc, iam-role, rds, elasticache]

Testing

  • ✅ All unit tests pass
  • ✅ Build succeeds without errors
  • ✅ Linting passes with no issues
  • ✅ Code follows Atmos conventions and patterns

references

  • Linear issue: DEV-2980
  • Documentation: !append YAML function
  • Changelog: blog post append-yaml-function; roadmap milestone updated (Extensibility initiative)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a !append YAML function to append items to lists during configuration merging (per-field, preserves order, supports nested lists/maps, interacts with global list-merge strategies).
  • Tests
    • Added comprehensive unit and integration tests covering append-tag helpers, parsing, merging, and end-to-end scenarios.
  • Documentation
    • Added docs, examples, blog post, and index updates explaining !append usage and behavior.
  • Chores
    • Updated website roadmap/metadata and package config; added a sentinel error alias.

@github-actions github-actions Bot added the size/l Large size PR label Sep 25, 2025
@coderabbitai

coderabbitai Bot commented Sep 25, 2025 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds 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.

Changes

YAML processing

Layer / File(s) Summary
Parse-time custom-tag rewrite & stack-unmarshal tests
pkg/utils/yaml_utils.go, pkg/utils/yaml_func_append_stack_test.go
Add AtmosYamlFuncAppend = "!append", detect !append as a custom tag, and rewrite sequence nodes into a mapping wrapper for downstream append handling; tests verify rewrite, nested cases, list-of-maps, inner-tag preservation, non-sequence no-op, and fast-path detection.
Config handlers and preprocess
pkg/config/process_yaml.go, pkg/config/process_yaml_append.go, pkg/config/process_yaml_append_test.go, pkg/config/process_yaml_git.go
processSequenceNode delegates !append sequences to handleAppend, which decodes items, wraps them with append metadata, writes to Viper at currentPath, and clears the tag. Git-related tag handlers were moved/implemented in process_yaml_git.go. Tests validate wrapped values and round-trip contract.
Append metadata utilities
pkg/utils/yaml_func_append.go, pkg/utils/yaml_func_append_test.go
Introduce AppendTagMetadataKey = "__atmos_append__" and helpers HasAppendTag, ExtractAppendListValue, WrapWithAppendTag, with unit tests covering detection, extraction, and wrapping variants.
Merge pre-processing & tests
pkg/merge/merge.go, pkg/merge/merge_append_test.go
MergeWithOptions now runs processAppendTags on inputs before deepMergeNative. New helpers processAppendTags, processValue, processAppendList, processNestedMap detect append-wrapped lists and either extract only new items (to avoid double-appending under global append strategies) or allocate concatenated slices with overflow protection. Comprehensive tests cover per-field append, interaction with global list merge strategy, chaining across inputs, list-of-maps, immutability, and end-to-end YAML merging.
E2E test-cases
tests/test-cases/append-function/*
Add base, override-with-append, and expected-result fixtures demonstrating !append behavior for node groups and depends_on lists.
Docs & blog
docs/prd/yaml-append-function.md, website/docs/functions/yaml/append.mdx, website/docs/functions/yaml/index.mdx, website/blog/2026-06-06-append-yaml-function.mdx, website/src/data/roadmap.js
PRD, user docs, examples, blog post, and roadmap updated to document !append semantics, examples, and release status.
Tests & harness
tests/cli_test.go
Add validateAtmosBinary(repoRoot string) and integrate into TestMain to provide a skip reason or detected binary path for CLI-related tests.
Errors
errors/errors.go
Add exported alias ErrRefusingToDeleteSymlink for the existing symbolic-link deletion refusal sentinel.

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
Loading
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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • cloudposse/atmos#2558 — touches YAML custom-tag machinery and git metadata tag handling; likely related to relocated git tag handlers.

Suggested reviewers

  • aknysh
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: implementing the !append YAML function for list concatenation during stack merging.
Docstring Coverage ✅ Passed Docstring coverage is 85.11% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/dev-2980-implement-append-function

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (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.

📥 Commits

Reviewing files that changed from the base of the PR and between e5a6b31 and 9755e5b.

📒 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.yaml
  • tests/test-cases/append-function/base.yaml
  • tests/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.go
  • pkg/config/process_yaml.go
  • pkg/utils/yaml_utils.go
  • pkg/merge/merge_append_test.go
  • pkg/utils/yaml_func_append_test.go
  • 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/merge/merge.go
  • pkg/config/process_yaml.go
  • pkg/utils/yaml_utils.go
  • pkg/merge/merge_append_test.go
  • pkg/utils/yaml_func_append_test.go
  • 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/merge/merge.go
  • pkg/config/process_yaml.go
  • pkg/utils/yaml_utils.go
  • pkg/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.go
  • pkg/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.go
  • pkg/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.

Comment thread pkg/utils/yaml_func_append.go Resolved
@codecov

codecov Bot commented Sep 25, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.10063% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.92%. Comparing base (2867836) to head (fc15b6d).

Files with missing lines Patch % Lines
pkg/config/process_yaml_git.go 68.75% 9 Missing and 6 partials ⚠️
pkg/config/process_yaml_append.go 60.60% 11 Missing and 2 partials ⚠️
pkg/merge/merge.go 86.04% 3 Missing and 3 partials ⚠️
pkg/utils/yaml_utils.go 78.94% 2 Missing and 2 partials ⚠️

❌ 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

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 78.92% <76.10%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
errors/errors.go 100.00% <ø> (ø)
pkg/config/process_yaml.go 72.59% <100.00%> (+0.61%) ⬆️
pkg/utils/yaml_func_append.go 100.00% <100.00%> (ø)
pkg/utils/yaml_utils.go 85.62% <78.94%> (-0.29%) ⬇️
pkg/merge/merge.go 83.84% <86.04%> (+0.31%) ⬆️
pkg/config/process_yaml_append.go 60.60% <60.60%> (ø)
pkg/config/process_yaml_git.go 68.75% <68.75%> (ø)

... and 7 files with indirect coverage changes

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

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Sep 25, 2025
coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 25, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 9755e5b and b3d174c.

📒 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.mdx
  • website/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.

Comment thread pkg/utils/yaml_func_append.go Resolved
coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 26, 2025
@mergify

mergify Bot commented Sep 26, 2025

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added conflict This PR has conflicts and removed conflict This PR has conflicts labels Sep 26, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

📥 Commits

Reviewing files that changed from the base of the PR and between b3d174c and 743c125.

📒 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.yaml
  • tests/cli_test.go
  • tests/test-cases/append-function/expected-result.yaml
  • tests/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.yaml
  • tests/test-cases/append-function/expected-result.yaml
  • tests/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.go
  • pkg/merge/merge.go
  • tests/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.go
  • pkg/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.

Comment thread errors/errors.go Resolved
Comment thread pkg/merge/merge.go Resolved
Comment thread tests/cli_test.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-level skipReason, preventing tests from skipping when they should. Use = with a local declaration for binaryPath.

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), processAppendList expands the list to include existing items, then mergo.WithAppendSlice appends again, causing duplication. Pass the appendSlice flag 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 appendNewOnly flag 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 743c125 and ff9bca7.

📒 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.go
  • pkg/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.go
  • tests/cli_test.go
  • pkg/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.go
  • pkg/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.go
  • pkg/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.go
  • 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.
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.

Comment thread pkg/config/process_yaml.go Resolved
@mergify

mergify Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

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.
Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

@mergify

mergify Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Dec 8, 2025
@github-actions github-actions Bot added size/l Large size PR and removed size/xl Extra large size PR labels Dec 8, 2025
@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown

Warning

Changelog Entry Required

This PR is labeled minor or major but doesn't include a changelog entry.

Action needed: Add a new blog post in website/blog/ to announce this change.

Example filename: website/blog/2025-12-08-feature-name.mdx

Alternatively: If this change doesn't require a changelog entry, remove the minor or major label.

Andriy Knysh (aknysh) and others added 2 commits June 6, 2026 12:14
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]>
@atmos-pro

atmos-pro Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

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

@aknysh

Copy link
Copy Markdown
Member

CodeRabbit (@coderabbitai) full review please

@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor
🧩 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 -C3

Length 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 f

Length of output: 12806



@aknysh Sure! Here's the full review of PR #1513.


Review: feat: implement !append YAML function for list concatenation

Summary

The implementation is solid. The two-phase design (parse-time tag rewriting → merge-time list concatenation) is clean, tests are thorough (chained appends, type mismatches, immutability, list-of-maps, end-to-end from YAML), and the overflow guard in processAppendList is good defensive coding. A few issues worth addressing before merge:


🔴 Medium — AtmosYamlFuncAppend missing from AtmosYamlTags slice and atmosYamlTagsMap

File: pkg/utils/yaml_utils.go

AtmosYamlFuncAppend is defined at Line 43 but intentionally absent from the AtmosYamlTags slice (Lines 62–89) and the atmosYamlTagsMap (Lines 94–121). The code works around this with hard-coded manual checks at Line 991 (hasCustomTags) and Line 898 (processCustomTagsInner):

// Line 991 — manual check, not using the shared map
if atmosYamlTagsMap[tag] || tag == AtmosYamlFuncInclude || tag == AtmosYamlFuncIncludeRaw || tag == AtmosYamlFuncAppend {

Any future code that iterates AtmosYamlTags or consults atmosYamlTagsMap for completeness (e.g., documentation generators, schema validators, linters, tag-dispatch tables) will silently miss !append. The fix is straightforward — add it to both:

// In AtmosYamlTags slice
AtmosYamlFuncAppend,

// In atmosYamlTagsMap
AtmosYamlFuncAppend: true,

🔴 Medium — Nested custom tags inside !append items are silently ignored in the atmos.yaml path

File: pkg/config/process_yaml_append.go

handleAppend decodes each child item via raw child.Decode(&value), bypassing all custom-tag processing:

for _, child := range node.Content {
    var value any
    if err := child.Decode(&value); err != nil { ... }
    list = append(list, value)
}

By contrast, the stack-manifest path (rewriteAppendNode in pkg/utils/yaml_utils.go) correctly calls processCustomTagsInner before wrapping:

if err := processCustomTagsInner(atmosConfig, &inner, file); err != nil {
    return err
}

This means that in atmos.yaml, an !append list whose items carry !env, !exec, !cwd, etc. will have those tags silently un-evaluated. Example that would silently break:

# atmos.yaml
some_list: !append
  - !env MY_VALUE
  - static-item

Even if this pattern isn't currently documented or expected in atmos.yaml, the behavioral inconsistency is a latent footgun. Consider processing each child with processSequenceElement (already in process_yaml.go) or invoking the same custom-tag pass used by rewriteAppendNode.


🟡 Minor — Documentation typo: import: vs imports:

File: website/docs/functions/yaml/append.mdx

The prod.yaml example block uses the wrong key name:

# ❌ incorrect
import:
  - base

The correct Atmos stack key is imports::

# ✅ correct
imports:
  - base

🟢 Trivial — expected-result.yaml missing trailing newline

File: tests/test-cases/append-function/expected-result.yaml

The file has no trailing newline. Most editors and POSIX tools expect one. Easy one-character fix.


Positive callouts

  • Test coverage is excellent: TestMergeAppend_ChainedAcrossThreeInputs, TestMergeAppend_DoesNotMutateInputs, TestMergeAppend_ExistingValueNotAList, and TestMergeAppend_EndToEndFromStackManifests cover the non-obvious edge cases well.
  • Overflow guard in processAppendList: the maxSliceCapacity check before allocation is good defensive coding.
  • MergeWithProvenance compatibility: MergeWithProvenance delegates to Merge() internally, so processAppendTags is called correctly — no issue there.
  • Backward compatibility: the opt-in !append tag has zero impact on configs that don't use it.

🧠 Learnings used
Learnt from: nitrocode
Repo: cloudposse/atmos PR: 0
File: :0-0
Timestamp: 2026-03-19T16:14:01.659Z
Learning: In cloudposse/atmos PR `#1956`, the feature-flags PRD (docs/prd/feature-flags.md) uses `features:` as a dual-semantic key: in stack files it is an activation list (list of strings/maps), but in feature files it is a context key-value map providing `.features.*` template variables. This dual semantics was flagged as a critical weakness.
✅ Action performed

Full review finished.

Comment thread pkg/merge/merge.go Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Unify !append with the canonical custom-tag registries.

AtmosYamlFuncAppend is defined, but it is not registered in AtmosYamlTags/atmosYamlTagsMap. The current behavior depends on ad-hoc checks in processCustomTagsInner and hasCustomTags, 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 win

Resolve !append wrappers on the single-input fast path.

When there is exactly one non-empty input, the function returns DeepCopyMap directly and skips processAppendTags, so a lone !append value 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2867836 and 95a9b3d.

📒 Files selected for processing (21)
  • docs/prd/yaml-append-function.md
  • errors/errors.go
  • pkg/config/process_yaml.go
  • pkg/config/process_yaml_append.go
  • pkg/config/process_yaml_append_test.go
  • pkg/config/process_yaml_git.go
  • pkg/merge/merge.go
  • pkg/merge/merge_append_test.go
  • pkg/utils/yaml_func_append.go
  • pkg/utils/yaml_func_append_stack_test.go
  • pkg/utils/yaml_func_append_test.go
  • pkg/utils/yaml_utils.go
  • tests/cli_test.go
  • tests/test-cases/append-function/base.yaml
  • tests/test-cases/append-function/expected-result.yaml
  • tests/test-cases/append-function/override-with-append.yaml
  • website/blog/2026-06-06-append-yaml-function.mdx
  • website/docs/functions/yaml/append.mdx
  • website/docs/functions/yaml/index.mdx
  • website/package.json
  • website/src/data/roadmap.js

Comment thread pkg/config/process_yaml_append.go Resolved
Comment thread pkg/merge/merge_append_test.go Resolved
Comment thread tests/cli_test.go Resolved
Andriy Knysh (aknysh) and others added 3 commits June 6, 2026 12:59
- 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]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 6, 2026
Comment thread pkg/merge/merge.go Fixed
Comment thread pkg/merge/merge.go Fixed
…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]>
@aknysh
Andriy Knysh (aknysh) merged commit 4bf67b0 into main Jun 9, 2026
272 of 278 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the feature/dev-2980-implement-append-function branch June 9, 2026 02:29
@atmos-pro

atmos-pro Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

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

@github-actions

Copy link
Copy Markdown

These changes were released in v1.221.0-rc.7.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.221.0.

This branch was successfully deployed

1 active deployment
preview — fc15b6dc Deployed Jun 6, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants