Skip to content

fix: single quote support #1362 - #1560

Merged
Andriy Knysh (aknysh) merged 12 commits into
mainfrom
fix/single-quotes-support-1362
Oct 8, 2025
Merged

Andriy Knysh (aknysh) merged 12 commits into
mainfrom
fix/single-quotes-support-1362

Conversation

@Cerebrovinny

@Cerebrovinny Vinicius C. (Cerebrovinny) commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor

what

  • fix parsing of !terraform.output arguments that use single quotes around expressions with nested double quotes

why

testing

Issue output
CleanShot 2025-09-30 at 19 45 48@2x

After the fix single quote
CleanShot 2025-09-30 at 19 46 38@2x

Summary by CodeRabbit

  • Bug Fixes
    • Improved delimited-string parsing to handle quoting edge cases: retries with relaxed parsing on certain parse errors and trims matching surrounding quotes while preserving unmatched quotes and removing quoted empty values.
  • Tests
    • Added comprehensive tests for nested/escaped quotes, quoted empty values, unmatched quotes, and splitting edge cases.
  • Documentation
    • Expanded YAML function guidance with examples and tips for nested/mixed quotes and YQ bracket-notation across related functions.
  • Dependencies
    • Updated Azure identity SDK to a newer patch version.

@Cerebrovinny
Vinicius C. (Cerebrovinny) requested a review from a team as a code owner September 30, 2025 18:48
@github-actions github-actions Bot added the size/s Small size PR label Sep 30, 2025
@mergify mergify Bot added the triage Needs triage label Sep 30, 2025
@Cerebrovinny Vinicius C. (Cerebrovinny) added the bug 🐛 An issue with the system label Sep 30, 2025
@coderabbitai

coderabbitai Bot commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a lazy-quote retry to CSV parsing, trims matching surrounding single/double quotes and normalizes inner escaped quotes, removes empty tokens, extends unit tests for quoting edge cases, bumps an azidentity dependency, and expands YAML function docs with guidance on quoting and bracket notation.

Changes

Cohort / File(s) Summary
String parsing logic
pkg/utils/string_utils.go
Add internal read(lazy bool) helper to configure csv.Reader, retry parse with LazyQuotes=true when csv.ParseError wraps csv.ErrBareQuote, introduce trimMatchingQuotes to strip matching surrounding single/double quotes and normalize escaped inner quotes, and filter out empty tokens during post-processing.
Unit tests
pkg/utils/string_utils_test.go
Add/expand tests covering many quoting edge cases (nested quotes, escaped quotes, quoted empty values removal, LazyQuotes retry behavior), plus expanded tests for UniqueStrings and string-splitting helpers.
YAML function docs
website/docs/functions/yaml/env.mdx, website/docs/functions/yaml/include.mdx, website/docs/functions/yaml/terraform.output.mdx, website/docs/functions/yaml/terraform.state.mdx
Expand quoting guidance and examples: recommend wrapping full expressions in single quotes when inner double quotes are required, document YQ bracket-notation quoting for keys with special characters, add cross-reference notes that YAML functions share the same parser, include OS-specific examples and escaping tips.
Dependency
go.mod
Bump github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.12.0 → v1.13.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller as Caller
  participant Split as SplitStringByDelimiter
  participant CSV as csv.Reader

  Note over Split: Initial parse attempt (LazyQuotes=false)
  Caller->>Split: Split(input, delim)
  Split->>CSV: read(lazy=false)
  CSV-->>Split: parts or csv.ParseError

  alt csv.ParseError contains ErrBareQuote
    Note over Split: Retry with LazyQuotes=true
    Split->>CSV: read(lazy=true)
    CSV-->>Split: parts or error
  else other error
    Split-->>Caller: return error
  end

  Note over Split: Post-processing: trimMatchingQuotes + remove empty tokens
  Split-->>Caller: return tokens
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

patch

Suggested reviewers

  • osterman
  • milldr

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary fix for enabling single-quote support and references issue #1362, clearly summarizing the main change in parsing and documentation.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/single-quotes-support-1362

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 (2)
pkg/utils/string_utils.go (2)

33-41: Consider wrapping the returned error with context.

The error from read() is returned directly without wrapping. Per the coding guidelines, errors should be wrapped with context using fmt.Errorf("context: %w", err) or wrapped with static errors from errors/errors.go.

As per coding guidelines.

Consider applying this pattern:

 	parts, err := read(false)
 	if err != nil {
 		if parseErr, ok := err.(*csv.ParseError); ok && parseErr.Err == csv.ErrBareQuote {
 			parts, err = read(true)
 		}
 	}
 	if err != nil {
-		return nil, err
+		return nil, fmt.Errorf("failed to parse string by delimiter: %w", err)
 	}

55-64: Consider adding a doc comment for the helper.

The logic correctly strips matching single or double quotes from both ends. While doc comments are required only for exported functions per the guidelines, adding a brief comment here would improve maintainability.

+// trimMatchingQuotes removes matching single or double quotes from the start and end of a string.
 func trimMatchingQuotes(value string) string {
 	if len(value) >= 2 {
📜 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 dc3de40 and 7963fe5.

📒 Files selected for processing (2)
  • pkg/utils/string_utils.go (1 hunks)
  • pkg/utils/string_utils_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
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/utils/string_utils.go
  • pkg/utils/string_utils_test.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 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:

  • pkg/utils/string_utils.go
  • pkg/utils/string_utils_test.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/string_utils.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:

  • pkg/utils/string_utils_test.go
{pkg,cmd}/**/*_test.go

📄 CodeRabbit inference engine (CLAUDE.md)

Co-locate unit/command tests with implementation files using _test.go naming.

Files:

  • pkg/utils/string_utils_test.go
⏰ 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: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (4)
pkg/utils/string_utils_test.go (2)

48-54: Good test coverage for the single quote fix.

This test case validates the core behavior: single quotes are stripped while preserving nested double quotes. The expected output correctly shows the inner JSON path with its double quotes intact.


55-61: No changes needed for unmatched-quote handling. The code retries with LazyQuotes on ErrBareQuote and only trims matching quotes, so the leading lone quote is correctly preserved.

pkg/utils/string_utils.go (2)

25-31: Clean refactoring of the reader setup.

The inline helper eliminates duplication and makes the retry logic straightforward. Good use of a closure to parameterize LazyQuotes.


43-50: Post-processing logic looks solid.

The filtering and trimming steps are clear. The comment accurately describes both operations, and the implementation correctly handles empty strings before trimming.

Comment thread pkg/utils/string_utils.go Resolved
@Cerebrovinny Vinicius C. (Cerebrovinny) added the minor New features that do not break anything label Sep 30, 2025
Comment thread pkg/utils/string_utils.go Fixed
@codecov

codecov Bot commented Sep 30, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.56%. Comparing base (997216c) to head (f0ebdb4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1560      +/-   ##
==========================================
+ Coverage   64.46%   64.56%   +0.09%     
==========================================
  Files         330      330              
  Lines       37011    37039      +28     
==========================================
+ Hits        23859    23913      +54     
+ Misses      11242    11214      -28     
- Partials     1910     1912       +2     
Flag Coverage Δ
unittests 64.56% <100.00%> (+0.09%) ⬆️

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

Files with missing lines Coverage Δ
pkg/utils/string_utils.go 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 30, 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: 0

🧹 Nitpick comments (1)
pkg/utils/string_utils_test.go (1)

48-82: Strong test coverage overall; consider a few more edge cases.

The five new tests provide excellent coverage of the quoting scenarios and directly address the previous feedback. Consider adding tests for:

  • Mixed single and double quotes in the same field: "foo'bar'baz"
  • Trailing unmatched quote: foo bar'
  • Multiple consecutive delimiters with quotes: foo '' bar

These would further strengthen confidence in the parser's robustness.

📜 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 5f8f537 and 3bec21e.

📒 Files selected for processing (2)
  • pkg/utils/string_utils.go (2 hunks)
  • pkg/utils/string_utils_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/utils/string_utils.go
🧰 Additional context used
📓 Path-based instructions (4)
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/utils/string_utils_test.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:

  • pkg/utils/string_utils_test.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 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:

  • pkg/utils/string_utils_test.go
{pkg,cmd}/**/*_test.go

📄 CodeRabbit inference engine (CLAUDE.md)

Co-locate unit/command tests with implementation files using _test.go naming.

Files:

  • pkg/utils/string_utils_test.go
⏰ 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). (5)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (5)
pkg/utils/string_utils_test.go (5)

48-54: Excellent coverage of the primary bug fix.

This test directly addresses issue #1362 where single quotes wrap expressions containing nested double quotes. The expected behavior correctly strips the outer single quotes while preserving the inner double quotes.


55-61: Good response to previous feedback.

This test addresses the earlier request for coverage of nested single quotes. The CSV-style escaping (doubled quotes) is handled correctly, converting '' to a literal single quote in the output.


62-68: Solid symmetrical coverage.

This test properly validates the CSV-style escaping for double quotes, mirroring the single quote escaping test. The expected behavior is correct.


69-75: Good edge case for empty quoted values.

This test validates that both single and double quoted empty strings are filtered from the result. The expected behavior aligns with the implementation's post-processing step.


76-82: Verify that retaining unmatched leading quotes is intentional.

This test demonstrates that when an input contains an unmatched leading quote, it’s preserved instead of causing an error—confirm that this matches the desired parsing semantics.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 30, 2025
@osterman

Copy link
Copy Markdown
Member

Vinicius C. (@Cerebrovinny) also need to update the docs that this is supported

@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 3bec21e and c4f681c.

📒 Files selected for processing (4)
  • website/docs/functions/yaml/env.mdx (1 hunks)
  • website/docs/functions/yaml/include.mdx (2 hunks)
  • website/docs/functions/yaml/terraform.output.mdx (1 hunks)
  • website/docs/functions/yaml/terraform.state.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • website/docs/functions/yaml/terraform.output.mdx
🧰 Additional context used
📓 Path-based instructions (1)
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/terraform.state.mdx
  • website/docs/functions/yaml/include.mdx
  • website/docs/functions/yaml/env.mdx
🧠 Learnings (3)
📚 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/terraform.state.mdx
  • website/docs/functions/yaml/env.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/include.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/env.mdx
⏰ 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 (ubuntu-latest, linux)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: website-deploy-preview
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: autofix
  • GitHub Check: Summary
🔇 Additional comments (2)
website/docs/functions/yaml/env.mdx (1)

76-90: Guidance aligns with the parser fix nicely.

The single-quote wrapping advice matches the new CSV parsing path and will spare folks from the bare-quote errors. 👍

website/docs/functions/yaml/terraform.state.mdx (1)

127-173: Nice cross-linking and defaults coverage.

The bracket-notation reminder plus the expanded default-value patterns mirror the parser rules cleanly—this should save a lot of trial-and-error.

Comment thread website/docs/functions/yaml/include.mdx Resolved
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 1, 2025
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 6, 2025
@aknysh Andriy Knysh (aknysh) added no-release Do not create a new release (wait for additional code changes) and removed minor New features that do not break anything labels Oct 7, 2025
Comment thread pkg/utils/string_utils_test.go Resolved

@aknysh Andriy Knysh (aknysh) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, one comment

@aknysh Andriy Knysh (aknysh) added minor New features that do not break anything and removed no-release Do not create a new release (wait for additional code changes) labels Oct 8, 2025
@aknysh

Copy link
Copy Markdown
Member

CodeRabbit (@coderabbitai) full review

@coderabbitai

coderabbitai Bot commented Oct 8, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@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 997216c and 9fcf6c7.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • go.mod (1 hunks)
  • pkg/utils/string_utils.go (2 hunks)
  • pkg/utils/string_utils_test.go (1 hunks)
  • website/docs/functions/yaml/env.mdx (1 hunks)
  • website/docs/functions/yaml/include.mdx (2 hunks)
  • website/docs/functions/yaml/terraform.output.mdx (1 hunks)
  • website/docs/functions/yaml/terraform.state.mdx (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 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/include.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/env.mdx
📚 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/env.mdx
  • website/docs/functions/yaml/terraform.output.mdx
  • website/docs/functions/yaml/terraform.state.mdx
📚 Learning: 2025-09-30T19:03:50.738Z
Learnt from: Cerebrovinny
PR: cloudposse/atmos#1560
File: pkg/utils/string_utils.go:43-64
Timestamp: 2025-09-30T19:03:50.738Z
Learning: In the Atmos codebase, YAML tags like !terraform.output rely on positional arguments, so the SplitStringByDelimiter function in pkg/utils/string_utils.go must preserve empty strings (even after trimming quotes) to maintain the correct number of positional arguments. Filtering out empty values after trimming would collapse the array and break these function calls.

Applied to files:

  • pkg/utils/string_utils.go
📚 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/terraform.output.mdx
⏰ 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). (3)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (10)
pkg/utils/string_utils.go (4)

5-5: LGTM!

The errors import is correctly added to support the new error checking logic.


32-38: LGTM!

The read helper function eliminates duplication and makes the lazy-quote retry logic clean.


63-88: LGTM!

The trimMatchingQuotes function correctly:

  • Handles matching quotes (single or double)
  • Normalizes escaped quotes ('' → ', "" → ")
  • Returns early for non-quoted or mismatched values

Good implementation.


50-58: Confirm intentional empty‐string removal vs. positional args
Filtering now drops trimmed‐empty parts (tests “Quoted empty values are removed”), which may shift positional arguments for YAML tags like !terraform.output; verify no tag functions rely on empty args or adjust accordingly.

pkg/utils/string_utils_test.go (1)

52-88: LGTM!

The new test cases provide solid coverage of quoting edge cases:

  • Nested double quotes inside single quotes
  • Escaped single quotes
  • Escaped double quotes
  • Empty value removal
  • Unmatched quote handling

Test expectations align with the implementation.

website/docs/functions/yaml/terraform.output.mdx (1)

128-160: LGTM!

The new section clearly explains:

  • Why single quotes are needed around expressions with bracket notation
  • Concrete examples with special characters in keys
  • Quote escaping rules
  • Cross-function applicability

Well-documented with practical examples.

website/docs/functions/yaml/env.mdx (1)

76-90: LGTM!

The nested quotes guidance is clear with practical examples. The cross-reference to !terraform.output documentation avoids duplication and helps users find detailed escaping rules.

website/docs/functions/yaml/terraform.state.mdx (1)

127-129: LGTM!

Concise cross-reference avoids documentation duplication while ensuring users can find the quoting guidance.

website/docs/functions/yaml/include.mdx (1)

244-278: LGTM!

The expanded quoting guidance provides:

  • Platform-specific examples (Windows vs macOS/Linux)
  • Bracket notation handling
  • Cross-reference to detailed escaping rules

The wording "around the whole expression" refers to the arguments passed to !include, not the YAML tag itself—the examples demonstrate this correctly.

go.mod (1)

9-9: Confirm intentional bump of github.com/Azure/azure-sdk-for-go/sdk/azidentity to v1.13.0
No known security advisories affect v1.13.0 (first patched was v1.6.0-beta…), but this update is unrelated to YAML parsing—ensure it’s required for this PR or revert it.

Comment thread pkg/utils/string_utils.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: 0

🧹 Nitpick comments (1)
pkg/utils/string_utils_test.go (1)

52-110: Add nested single quotes test
The TestSplitStringByDelimiter suite passes existing cases but lacks coverage for inputs like 'foo 'bar' baz'. Add a test case to verify this scenario.

📜 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 9fcf6c7 and f0ebdb4.

📒 Files selected for processing (2)
  • pkg/utils/string_utils.go (2 hunks)
  • pkg/utils/string_utils_test.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/utils/string_utils.go
🧰 Additional context used
📓 Path-based instructions (5)
pkg/**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

Place business logic in pkg rather than in cmd

Files:

  • pkg/utils/string_utils_test.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; focus on pure functions; generate and use mocks for external dependencies.
Test behavior, not implementation; avoid tautological or stub tests; remove always-skipped tests; ensure tests validate real behavior.
Always use t.Skipf() with a reason for skipped tests; never call t.Skipf without a reason; CLI tests build a temp binary and TestMain must call os.Exit(m.Run()).

Files:

  • pkg/utils/string_utils_test.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 comments must end with periods; comments should be complete sentences (golangci-lint godot).
Organize imports into three groups separated by blank lines: standard library, third-party, and github.com/cloudposse/atmos packages; sort alphabetically within each group and preserve existing aliases.
Wrap all errors using static errors from errors/errors.go; prefer errors.Join for multiple errors; use fmt.Errorf with %w for context; check with errors.Is; never use dynamic errors directly.
Distinguish structured logging from UI output: use stderr for prompts/status/errors needing user action, stdout only for data; never use logging for UI elements.
Most text UI must go to stderr; only data/results go to stdout; prefer utils.PrintfMessageToTUI for UI messages.
Ensure cross-platform compatibility: prefer SDKs over external binaries; use filepath.Join, os.PathSeparator, and runtime.GOOS for OS-specific logic; add build constraints if needed.

Files:

  • pkg/utils/string_utils_test.go
pkg/**/*_test.go

📄 CodeRabbit inference engine (CLAUDE.md)

Unit test files should mirror implementation structure within pkg/ (test naming symmetry).

Files:

  • pkg/utils/string_utils_test.go
@(cmd|internal|pkg)/**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

Bind environment variables with viper.BindEnv() and provide ATMOS_ alternatives for every env var.

Files:

  • pkg/utils/string_utils_test.go
⏰ 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: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Build (ubuntu-latest, linux)
  • 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: Summary
🔇 Additional comments (3)
pkg/utils/string_utils_test.go (3)

166-185: Solid edge case additions.

The new test cases for nil input, single elements, order preservation, and empty string handling provide good coverage of boundary conditions and expected behavior.


196-271: Comprehensive test coverage for quote trimming.

The new TestTrimMatchingQuotes function thoroughly exercises the quote trimming logic with excellent coverage of edge cases including escaped quotes, mismatched quotes, empty inputs, and boundary conditions. The table-driven structure aligns with coding guidelines.


311-322: Good boundary and multi-character separator coverage.

These additions properly test the separator-at-end edge case and multi-character separator handling, rounding out the test suite for this function.

@aknysh
Andriy Knysh (aknysh) merged commit f69c0b4 into main Oct 8, 2025
@aknysh
Andriy Knysh (aknysh) deleted the fix/single-quotes-support-1362 branch October 8, 2025 16:47
@github-actions

github-actions Bot commented Oct 8, 2025

Copy link
Copy Markdown

These changes were released in v1.194.0.

This branch was successfully deployed

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

Labels

bug 🐛 An issue with the system minor New features that do not break anything size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants