Skip to content

fix: !exec returning executable not found - !exec should preserve PATH - #1634

Merged
Andriy Knysh (aknysh) merged 5 commits into
cloudposse:mainfrom
ohaibbq:dan/exec-path-fix
Oct 15, 2025
Merged

Andriy Knysh (aknysh) merged 5 commits into
cloudposse:mainfrom
ohaibbq:dan/exec-path-fix

Conversation

@ohaibbq

@ohaibbq Dan Hansen (ohaibbq) commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor

what

#1543 introduced a breaking change to the !exec yaml function whereby the parent process's environment was not inherited if an environment was explicitly passed. !exec uses ExecuteShellAndReturnOutput which passes the shell level as an environment variable, causing the PATH not to be inherited.

env = append(env, fmt.Sprintf("ATMOS_SHLVL=%d", newShellLevel))
log.Debug("Executing", "command", command)
if dryRun {
return "", nil
}
err = ShellRunner(command, name, dir, env, &b)

why

Stacks using !exec with custom binaries fail with executable not found errors

references

#1543

Summary by CodeRabbit

  • Bug Fixes

    • Shell-executed commands now inherit environment variables, improving compatibility with scripts and external tools.
  • Tests

    • Added comprehensive cross-platform unit tests for execution outputs (strings, numbers, empty), complex JSON parsing (objects, arrays, booleans, null), invalid JSON handling, and error scenarios (invalid commands, malformed input) using temporary executables and PATH manipulation.

@ohaibbq
Dan Hansen (ohaibbq) requested a review from a team as a code owner October 15, 2025 17:57
@coderabbitai

coderabbitai Bot commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Pass environment variables (os.Environ()) into executed shell commands in yaml_func_exec and add comprehensive cross-platform unit tests for ProcessTagExec covering outputs, JSON parsing, errors, and malformed tags.

Changes

Cohort / File(s) Summary
Utils: Exec env propagation
pkg/utils/yaml_func_exec.go
Import os; change call to ExecuteShellAndReturnOutput to pass os.Environ() instead of nil. No other logic or error-handling changes.
Tests: ProcessTagExec coverage
pkg/utils/yaml_func_exec_test.go
Add comprehensive unit tests that create temporary executables (shell script on Unix, batch on Windows), modify PATH, and validate ProcessTagExec handling of plain strings, numbers, empty output, JSON objects/arrays (including nested), malformed JSON, invalid commands, and malformed tags. Tests clean up temp artifacts.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as ProcessTagExec
    participant Shell as ExecuteShellAndReturnOutput
    Note over Caller: Parse tag -> build shell command
    Caller->>Shell: Run command with env (os.Environ())
    activate Shell
    Shell-->>Caller: stdout/stderr + exit status
    deactivate Shell
    Note over Caller: Attempt JSON parse -> return parsed value or raw string / error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

patch

Suggested reviewers

  • aknysh

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 clearly identifies the bug and its resolution by stating that the !exec function was failing due to PATH not being preserved and that the fix restores PATH inheritance, directly reflecting the primary change in the code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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

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.

@mergify mergify Bot added the triage Needs triage label Oct 15, 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: 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 82ff97a and 5e9afe5.

📒 Files selected for processing (2)
  • pkg/utils/yaml_func_exec.go (2 hunks)
  • pkg/utils/yaml_func_exec_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

Files:

  • pkg/utils/yaml_func_exec_test.go
  • pkg/utils/yaml_func_exec.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: Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.
Use t.Skipf with a reason instead of t.Skip; never skip without a reason.
Test files must mirror implementation file names (e.g., aws_ssm_store_test.go pairs with aws_ssm_store.go).

Files:

  • pkg/utils/yaml_func_exec_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 across all Go code (godot linter enforced).
Organize imports into three groups (stdlib, 3rd-party, Atmos) separated by blank lines and sorted alphabetically within groups; preserve existing aliases.
Add defer perf.Track(<atmosConfig|nil>, ".")() at the start of all public and critical private functions, followed by a blank line.
All errors must be wrapped using static errors from errors/errors.go; prefer errors.Join for multiple errors, fmt.Errorf with %w for context, and check with errors.Is; never use dynamic errors directly.
Use utils.PrintfMarkdown() to render embedded markdown examples for CLI help output.
Co-locate unit tests with implementation files; integration tests reside under tests/.
Distinguish UI output from logging: UI prompts/status/errors to stderr; data/results to stdout; logging for system/debug info only with structured fields.
Most text UI must go to stderr; only data/results to stdout. Prefer utils.PrintfMessageToTUI for UI messages.
Bind all environment variables with viper.BindEnv(); every env var must have an ATMOS_ alternative binding.
Favor cross-platform code: prefer SDKs over external binaries, use filepath/os/runtime, and handle OS-specific differences or use build tags.
For non-standard execution paths, capture telemetry using telemetry.CaptureCmd or telemetry.CaptureCmdString without collecting user data.
Search for existing methods and utilities (internal/exec, pkg/) before implementing new functionality; prefer reuse/refactoring over duplication.

Files:

  • pkg/utils/yaml_func_exec_test.go
  • pkg/utils/yaml_func_exec.go
pkg/**/*_test.go

📄 CodeRabbit inference engine (CLAUDE.md)

Place unit tests for packages under pkg/ as *_test.go files.

Files:

  • pkg/utils/yaml_func_exec_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/yaml_func_exec.go
🧠 Learnings (1)
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to internal/exec/template_funcs.go : Add new template functions in internal/exec/template_funcs.go and add comprehensive tests and documentation if user-facing.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
🧬 Code graph analysis (2)
pkg/utils/yaml_func_exec_test.go (1)
pkg/utils/yaml_func_exec.go (1)
  • ProcessTagExec (11-34)
pkg/utils/yaml_func_exec.go (1)
pkg/utils/shell_utils.go (1)
  • ExecuteShellAndReturnOutput (32-61)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (9)
pkg/utils/yaml_func_exec.go (2)

5-5: LGTM!

The import is necessary for accessing os.Environ() below.


22-22: Correctly passes environment variables to shell execution.

This change fixes the issue where !exec was not inheriting the parent process environment, particularly the PATH variable. The os.Environ() call provides the complete environment, which ExecuteShellAndReturnOutput will augment with ATMOS_SHLVL.

pkg/utils/yaml_func_exec_test.go (7)

13-65: Excellent cross-platform test setup.

The test properly handles both Unix and Windows environments by creating appropriate script files and managing PATH modifications. The cleanup with deferred functions ensures proper resource management.


66-117: Well-structured table-driven test with comprehensive scenarios.

The test cases cover string output, JSON parsing, arrays, empty output, and numeric conversion. Good use of table-driven testing pattern.


139-191: Thorough test for complex JSON structures.

This test verifies that nested objects, arrays, booleans, and null values are correctly parsed, ensuring robust JSON handling.


194-239: Good validation of fallback behavior.

This test confirms that when JSON parsing fails, the output is returned as a string rather than producing an error, which matches the implementation in yaml_func_exec.go.


12-12: Comment is missing a period.

According to coding guidelines, all comments must end with periods.

Apply this diff:

-// TestProcessTagExec_CustomBinary tests the ProcessTagExec function using a custom bash binary
+// TestProcessTagExec_CustomBinary tests the ProcessTagExec function using a custom bash binary.
⛔ Skipped due to learnings
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to internal/exec/template_funcs.go : Add new template functions in internal/exec/template_funcs.go and add comprehensive tests and documentation if user-facing.

193-239: Comment is missing a period.

According to coding guidelines, all comments must end with periods.

Apply this diff:

-// TestProcessTagExec_InvalidJSON tests handling of invalid JSON that should be returned as string
+// TestProcessTagExec_InvalidJSON tests handling of invalid JSON that should be returned as string.
⛔ Skipped due to learnings
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*.go : All comments must end with periods across all Go code (godot linter enforced).
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.

138-191: Comment is missing a period.

According to coding guidelines, all comments must end with periods.

Apply this diff:

-// TestProcessTagExec_ComplexJSON tests parsing of complex JSON output
+// TestProcessTagExec_ComplexJSON tests parsing of complex JSON output.
⛔ Skipped due to learnings
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*.go : All comments must end with periods across all Go code (godot linter enforced).
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.

Comment thread pkg/utils/yaml_func_exec_test.go Resolved
Comment thread pkg/utils/yaml_func_exec_test.go Resolved
@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Oct 15, 2025
@aknysh Andriy Knysh (aknysh) added no-release Do not create a new release (wait for additional code changes) and removed patch A minor, backward compatible change labels Oct 15, 2025
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 15, 2025
@mergify mergify Bot removed the triage Needs triage label Oct 15, 2025
@codecov

codecov Bot commented Oct 15, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.96%. Comparing base (82ff97a) to head (533ead8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1634      +/-   ##
==========================================
+ Coverage   64.88%   64.96%   +0.08%     
==========================================
  Files         337      337              
  Lines       37448    37448              
==========================================
+ Hits        24297    24328      +31     
+ Misses      11205    11177      -28     
+ Partials     1946     1943       -3     
Flag Coverage Δ
unittests 64.96% <100.00%> (+0.08%) ⬆️

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

Files with missing lines Coverage Δ
pkg/utils/yaml_func_exec.go 100.00% <100.00%> (+33.33%) ⬆️

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

133-181: Consider extracting common test setup.

The temp binary creation and PATH manipulation logic is duplicated from TestProcessTagExec_CustomBinary. Consider extracting this into a helper function to reduce duplication and improve maintainability.

Example helper:

func setupTempBinary(t *testing.T, scriptContent string) (cleanup func()) {
	tempDir := t.TempDir()
	customBinaryPath := filepath.Join(tempDir, "test-bash")
	if runtime.GOOS == "windows" {
		customBinaryPath += ".bat"
	}
	
	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
	assert.NoError(t, err)
	
	originalPath := os.Getenv("PATH")
	err = os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath)
	assert.NoError(t, err)
	
	return func() {
		err := os.Setenv("PATH", originalPath)
		assert.NoError(t, err)
	}
}

Then use it in tests:

cleanup := setupTempBinary(t, scriptContent)
defer cleanup()

183-224: Same duplication pattern.

This test also duplicates the temp binary setup logic. The same refactoring suggestion from the previous comment applies here.

📜 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 5e9afe5 and 00daac8.

📒 Files selected for processing (1)
  • pkg/utils/yaml_func_exec_test.go (1 hunks)
🧰 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

Files:

  • pkg/utils/yaml_func_exec_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: Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.
Use t.Skipf with a reason instead of t.Skip; never skip without a reason.
Test files must mirror implementation file names (e.g., aws_ssm_store_test.go pairs with aws_ssm_store.go).

Files:

  • pkg/utils/yaml_func_exec_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 across all Go code (godot linter enforced).
Organize imports into three groups (stdlib, 3rd-party, Atmos) separated by blank lines and sorted alphabetically within groups; preserve existing aliases.
Add defer perf.Track(<atmosConfig|nil>, ".")() at the start of all public and critical private functions, followed by a blank line.
All errors must be wrapped using static errors from errors/errors.go; prefer errors.Join for multiple errors, fmt.Errorf with %w for context, and check with errors.Is; never use dynamic errors directly.
Use utils.PrintfMarkdown() to render embedded markdown examples for CLI help output.
Co-locate unit tests with implementation files; integration tests reside under tests/.
Distinguish UI output from logging: UI prompts/status/errors to stderr; data/results to stdout; logging for system/debug info only with structured fields.
Most text UI must go to stderr; only data/results to stdout. Prefer utils.PrintfMessageToTUI for UI messages.
Bind all environment variables with viper.BindEnv(); every env var must have an ATMOS_ alternative binding.
Favor cross-platform code: prefer SDKs over external binaries, use filepath/os/runtime, and handle OS-specific differences or use build tags.
For non-standard execution paths, capture telemetry using telemetry.CaptureCmd or telemetry.CaptureCmdString without collecting user data.
Search for existing methods and utilities (internal/exec, pkg/) before implementing new functionality; prefer reuse/refactoring over duplication.

Files:

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

📄 CodeRabbit inference engine (CLAUDE.md)

Place unit tests for packages under pkg/ as *_test.go files.

Files:

  • pkg/utils/yaml_func_exec_test.go
🧠 Learnings (3)
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to internal/exec/template_funcs.go : Add new template functions in internal/exec/template_funcs.go and add comprehensive tests and documentation if user-facing.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*.go : All comments must end with periods across all Go code (godot linter enforced).

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
🧬 Code graph analysis (1)
pkg/utils/yaml_func_exec_test.go (1)
pkg/utils/yaml_func_exec.go (1)
  • ProcessTagExec (11-34)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
pkg/utils/yaml_func_exec_test.go (4)

1-10: LGTM!

Package declaration and imports are properly organized according to the coding guidelines.


12-112: Well-structured cross-platform test.

The test properly validates PATH preservation by creating temporary binaries and modifying PATH. The cross-platform handling is solid, and the table-driven approach covers various output scenarios effectively.


114-121: LGTM!

Error handling test is straightforward and correct. The comment period issue from the previous review has been addressed.


123-131: LGTM!

Malformed tag test is appropriate and the comment period issue from the previous review has been addressed.

@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/yaml_func_exec_test.go (1)

142-190: Consider extracting setup helper to reduce duplication.

The test logic is solid and covers complex JSON scenarios well. The setup code (creating temp binary and modifying PATH) is duplicated from TestProcessTagExec_CustomBinary. Consider extracting a helper function like setupTestBinary(t, scriptContent) (cleanup func()) to reduce maintenance burden.

📜 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 00daac8 and e7d74c9.

📒 Files selected for processing (1)
  • pkg/utils/yaml_func_exec_test.go (1 hunks)
🧰 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

Files:

  • pkg/utils/yaml_func_exec_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: Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.
Use t.Skipf with a reason instead of t.Skip; never skip without a reason.
Test files must mirror implementation file names (e.g., aws_ssm_store_test.go pairs with aws_ssm_store.go).

Files:

  • pkg/utils/yaml_func_exec_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 across all Go code (godot linter enforced).
Organize imports into three groups (stdlib, 3rd-party, Atmos) separated by blank lines and sorted alphabetically within groups; preserve existing aliases.
Add defer perf.Track(<atmosConfig|nil>, ".")() at the start of all public and critical private functions, followed by a blank line.
All errors must be wrapped using static errors from errors/errors.go; prefer errors.Join for multiple errors, fmt.Errorf with %w for context, and check with errors.Is; never use dynamic errors directly.
Use utils.PrintfMarkdown() to render embedded markdown examples for CLI help output.
Co-locate unit tests with implementation files; integration tests reside under tests/.
Distinguish UI output from logging: UI prompts/status/errors to stderr; data/results to stdout; logging for system/debug info only with structured fields.
Most text UI must go to stderr; only data/results to stdout. Prefer utils.PrintfMessageToTUI for UI messages.
Bind all environment variables with viper.BindEnv(); every env var must have an ATMOS_ alternative binding.
Favor cross-platform code: prefer SDKs over external binaries, use filepath/os/runtime, and handle OS-specific differences or use build tags.
For non-standard execution paths, capture telemetry using telemetry.CaptureCmd or telemetry.CaptureCmdString without collecting user data.
Search for existing methods and utilities (internal/exec, pkg/) before implementing new functionality; prefer reuse/refactoring over duplication.

Files:

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

📄 CodeRabbit inference engine (CLAUDE.md)

Place unit tests for packages under pkg/ as *_test.go files.

Files:

  • pkg/utils/yaml_func_exec_test.go
🧠 Learnings (3)
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to internal/exec/template_funcs.go : Add new template functions in internal/exec/template_funcs.go and add comprehensive tests and documentation if user-facing.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*.go : All comments must end with periods across all Go code (godot linter enforced).

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
🧬 Code graph analysis (1)
pkg/utils/yaml_func_exec_test.go (1)
pkg/utils/yaml_func_exec.go (1)
  • ProcessTagExec (11-34)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
pkg/utils/yaml_func_exec_test.go (4)

13-121: Strong test coverage for PATH preservation.

This test validates the PR fix effectively by creating a custom binary, adding it to PATH, and verifying it can be executed through ProcessTagExec. The table-driven approach covers key scenarios (string, JSON object/array, empty, numeric outputs) and handles cross-platform differences well.


123-130: LGTM!

Clean error handling test. The past review comment about the missing period has been addressed.


132-140: LGTM!

Good error handling test for malformed tags. The past review comment about the missing period has been addressed.


192-235: Good coverage of invalid JSON fallback.

The test correctly verifies that invalid JSON is returned as a string when parsing fails. The setup code duplication noted in the previous test applies here as well.

Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Oct 15, 2025
…ions

## what
- Removed `|| true` from the `make lintroller` target in Makefile
- Updated comment to include os.MkdirTemp in the list of rules
- Removed unnecessary `grep -v "^#"` filter that was suppressing output

## why
- The `|| true` caused lintroller to always exit with code 0, even when violations were found
- This meant pre-commit hooks would pass despite lintroller detecting issues
- PR #1634 initially contained os.MkdirTemp violations that weren't caught because of this bug
- The developer had to manually fix the violations in a second commit

## references
- Related to PR #1634 which had os.MkdirTemp violations that weren't caught
- The lintroller rule itself works correctly (added in PR #1630)
- The issue was only in the Makefile target that always returned success

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

@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 e7d74c9 and c993e4b.

📒 Files selected for processing (1)
  • pkg/utils/yaml_func_exec_test.go (1 hunks)
🧰 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

Files:

  • pkg/utils/yaml_func_exec_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: Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.
Use t.Skipf with a reason instead of t.Skip; never skip without a reason.
Test files must mirror implementation file names (e.g., aws_ssm_store_test.go pairs with aws_ssm_store.go).

Files:

  • pkg/utils/yaml_func_exec_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 across all Go code (godot linter enforced).
Organize imports into three groups (stdlib, 3rd-party, Atmos) separated by blank lines and sorted alphabetically within groups; preserve existing aliases.
Add defer perf.Track(<atmosConfig|nil>, ".")() at the start of all public and critical private functions, followed by a blank line.
All errors must be wrapped using static errors from errors/errors.go; prefer errors.Join for multiple errors, fmt.Errorf with %w for context, and check with errors.Is; never use dynamic errors directly.
Use utils.PrintfMarkdown() to render embedded markdown examples for CLI help output.
Co-locate unit tests with implementation files; integration tests reside under tests/.
Distinguish UI output from logging: UI prompts/status/errors to stderr; data/results to stdout; logging for system/debug info only with structured fields.
Most text UI must go to stderr; only data/results to stdout. Prefer utils.PrintfMessageToTUI for UI messages.
Bind all environment variables with viper.BindEnv(); every env var must have an ATMOS_ alternative binding.
Favor cross-platform code: prefer SDKs over external binaries, use filepath/os/runtime, and handle OS-specific differences or use build tags.
For non-standard execution paths, capture telemetry using telemetry.CaptureCmd or telemetry.CaptureCmdString without collecting user data.
Search for existing methods and utilities (internal/exec, pkg/) before implementing new functionality; prefer reuse/refactoring over duplication.

Files:

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

📄 CodeRabbit inference engine (CLAUDE.md)

Place unit tests for packages under pkg/ as *_test.go files.

Files:

  • pkg/utils/yaml_func_exec_test.go
🧠 Learnings (3)
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to internal/exec/template_funcs.go : Add new template functions in internal/exec/template_funcs.go and add comprehensive tests and documentation if user-facing.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*.go : All comments must end with periods across all Go code (godot linter enforced).

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
🧬 Code graph analysis (1)
pkg/utils/yaml_func_exec_test.go (1)
pkg/utils/yaml_func_exec.go (1)
  • ProcessTagExec (11-34)
⏰ 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). (1)
  • GitHub Check: Summary

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

🧹 Nitpick comments (5)
pkg/utils/yaml_func_exec_test.go (5)

53-61: Use t.Setenv for PATH; simpler, safer, no shadowing.

t.Setenv auto-restores and removes the need for defer + assert in three places.

Apply these diffs:

-	// Save original PATH and modify it to include our temp directory.
-	originalPath := os.Getenv("PATH")
-	defer func() {
-		err := os.Setenv("PATH", originalPath)
-		assert.NoError(t, err)
-	}()
-	err = os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath)
-	assert.NoError(t, err)
+	// Prepend temp dir to PATH for this test.
+	t.Setenv("PATH", tempDir+string(os.PathListSeparator)+os.Getenv("PATH"))
-	// Save original PATH and modify it to include our temp directory.
-	originalPath := os.Getenv("PATH")
-	defer func() {
-		err := os.Setenv("PATH", originalPath)
-		assert.NoError(t, err)
-	}()
-	err = os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath)
-	assert.NoError(t, err)
+	// Prepend temp dir to PATH for this test.
+	t.Setenv("PATH", tempDir+string(os.PathListSeparator)+os.Getenv("PATH"))
-	// Save original PATH and modify it to include our temp directory.
-	originalPath := os.Getenv("PATH")
-	defer func() {
-		err := os.Setenv("PATH", originalPath)
-		assert.NoError(t, err)
-	}()
-	err = os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath)
-	assert.NoError(t, err)
+	// Prepend temp dir to PATH for this test.
+	t.Setenv("PATH", tempDir+string(os.PathListSeparator)+os.Getenv("PATH"))

As per coding guidelines (cross‑platform preference).

Also applies to: 168-176, 218-226


3-11: Import require alongside assert.

Will use require for setup failures.

 import (
 	"os"
 	"path/filepath"
 	"runtime"
 	"strings"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 )

50-52: Fail fast on setup errors with require.

Setup failures should stop the test immediately.

-	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
-	assert.NoError(t, err)
+	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
+	require.NoError(t, err)
-	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
-	assert.NoError(t, err)
+	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
+	require.NoError(t, err)
-	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
-	assert.NoError(t, err)
+	err := os.WriteFile(customBinaryPath, []byte(scriptContent), 0o755)
+	require.NoError(t, err)

Based on learnings.

Also applies to: 165-167, 215-217


37-47: Prefer #!/usr/bin/env bash for portability.

More resilient when bash isn’t at /bin/bash.

-		scriptContent = `#!/bin/bash
+		scriptContent = `#!/usr/bin/env bash
 case "$1" in
-		scriptContent = `#!/bin/bash
+		scriptContent = `#!/usr/bin/env bash
 echo '{"nested": {"key": "value"}, "array": [1, 2, 3], "bool": true, "null": null}'
 `
-		scriptContent = `#!/bin/bash
+		scriptContent = `#!/usr/bin/env bash
 echo "invalid json {"
 `

As per coding guidelines (cross‑platform code).

Also applies to: 160-163, 210-213


18-49: DRY up script/Path scaffolding with a helper.

Extract a helper to write the script (with OS suffix) and prepend PATH; reuse across tests.

Example helper:

func makeTempExec(t *testing.T, body string) string {
	t.Helper()
	dir := t.TempDir()
	name := "test-bash"
	if runtime.GOOS == "windows" { name += ".bat" }
	path := filepath.Join(dir, name)
	require.NoError(t, os.WriteFile(path, []byte(body), 0o755))
	t.Setenv("PATH", dir+string(os.PathListSeparator)+os.Getenv("PATH"))
	return "test-bash"
}

Then in tests: bin := makeTempExec(t, scriptContent); input := "!exec " + bin + " simple".

Also applies to: 147-166, 197-215

📜 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 c993e4b and 533ead8.

📒 Files selected for processing (1)
  • pkg/utils/yaml_func_exec_test.go (1 hunks)
🧰 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

Files:

  • pkg/utils/yaml_func_exec_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: Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.
Use t.Skipf with a reason instead of t.Skip; never skip without a reason.
Test files must mirror implementation file names (e.g., aws_ssm_store_test.go pairs with aws_ssm_store.go).

Files:

  • pkg/utils/yaml_func_exec_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 across all Go code (godot linter enforced).
Organize imports into three groups (stdlib, 3rd-party, Atmos) separated by blank lines and sorted alphabetically within groups; preserve existing aliases.
Add defer perf.Track(<atmosConfig|nil>, ".")() at the start of all public and critical private functions, followed by a blank line.
All errors must be wrapped using static errors from errors/errors.go; prefer errors.Join for multiple errors, fmt.Errorf with %w for context, and check with errors.Is; never use dynamic errors directly.
Use utils.PrintfMarkdown() to render embedded markdown examples for CLI help output.
Co-locate unit tests with implementation files; integration tests reside under tests/.
Distinguish UI output from logging: UI prompts/status/errors to stderr; data/results to stdout; logging for system/debug info only with structured fields.
Most text UI must go to stderr; only data/results to stdout. Prefer utils.PrintfMessageToTUI for UI messages.
Bind all environment variables with viper.BindEnv(); every env var must have an ATMOS_ alternative binding.
Favor cross-platform code: prefer SDKs over external binaries, use filepath/os/runtime, and handle OS-specific differences or use build tags.
For non-standard execution paths, capture telemetry using telemetry.CaptureCmd or telemetry.CaptureCmdString without collecting user data.
Search for existing methods and utilities (internal/exec, pkg/) before implementing new functionality; prefer reuse/refactoring over duplication.

Files:

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

📄 CodeRabbit inference engine (CLAUDE.md)

Place unit tests for packages under pkg/ as *_test.go files.

Files:

  • pkg/utils/yaml_func_exec_test.go
🧠 Learnings (3)
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to internal/exec/template_funcs.go : Add new template functions in internal/exec/template_funcs.go and add comprehensive tests and documentation if user-facing.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*_test.go : Write unit tests as table-driven tests focused on behavior; prefer high coverage for pkg/ and internal/exec/; comments must end with periods.

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
📚 Learning: 2025-10-11T23:25:09.224Z
Learnt from: CR
PR: cloudposse/atmos#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-11T23:25:09.224Z
Learning: Applies to **/*.go : All comments must end with periods across all Go code (godot linter enforced).

Applied to files:

  • pkg/utils/yaml_func_exec_test.go
🧬 Code graph analysis (1)
pkg/utils/yaml_func_exec_test.go (1)
pkg/utils/yaml_func_exec.go (1)
  • ProcessTagExec (11-34)
⏰ 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). (1)
  • GitHub Check: Summary
🔇 Additional comments (1)
pkg/utils/yaml_func_exec_test.go (1)

13-121: Solid cross‑platform coverage; PATH inheritance verified.

This meaningfully guards the regression and exercises multiple output shapes. Nice.

@aknysh Andriy Knysh (aknysh) added the size/xs Extra small size PR label Oct 15, 2025

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

@aknysh
Andriy Knysh (aknysh) merged commit 032025e into cloudposse:main Oct 15, 2025
@github-actions

Copy link
Copy Markdown

These changes were released in v1.195.0-test.0.

Andriy Knysh (aknysh) pushed a commit that referenced this pull request Oct 17, 2025
…1636)

* fix: remove || true from lintroller Makefile target to enforce violations

## what
- Removed `|| true` from the `make lintroller` target in Makefile
- Updated comment to include os.MkdirTemp in the list of rules
- Removed unnecessary `grep -v "^#"` filter that was suppressing output

## why
- The `|| true` caused lintroller to always exit with code 0, even when violations were found
- This meant pre-commit hooks would pass despite lintroller detecting issues
- PR #1634 initially contained os.MkdirTemp violations that weren't caught because of this bug
- The developer had to manually fix the violations in a second commit

## references
- Related to PR #1634 which had os.MkdirTemp violations that weren't caught
- The lintroller rule itself works correctly (added in PR #1630)
- The issue was only in the Makefile target that always returned success

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* test: add comprehensive lintroller tests for all rules

## what
- Renamed testdata/src/a/bad.go to bad_test.go so rules properly apply
- Added test cases for os.Setenv in test files
- Added test cases for os.MkdirTemp in test files
- Added test cases for exceptions (benchmarks, defer blocks)
- Added comments documenting which rule each test validates

## why
- The original test file only covered t.Setenv in defer/cleanup
- Missing tests for os-setenv-in-test and os-mkdirtemp-in-test rules
- File needed _test.go suffix for lintroller rules to apply
- Comprehensive tests ensure all rules work as expected

## references
- All lintroller tests now pass with full coverage
- Validates the rules added in PR #1630

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* feat: integrate lintroller plugin into golangci-lint CI workflow

## what
- Enabled lintroller as a module plugin in .golangci.yml
- Added lintroller configuration in settings.custom section
- Updated CodeQL workflow to build custom golangci-lint with lintroller
- CI now runs lintroller as part of golangci-lint with SARIF output

## why
- Lintroller was only running standalone via pre-commit hooks
- Plugin system allows integration with golangci-lint for GitHub Advanced Security
- SARIF output enables CodeQL to display lintroller findings
- Custom plugin rules now integrated alongside standard golangci-lint linters
- Ensures os.MkdirTemp, os.Setenv violations are caught in CI with proper reporting

## references
- Lintroller plugin properly registers with golangci-lint v2 module plugin system
- Custom binary built via `golangci-lint custom` includes lintroller
- Tested and verified lintroller catches violations in custom-gcl binary

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: use golangci-lint-action with install-mode none for custom binary

## what
- Restored golangci-lint-action@v8 usage in CI
- Added install-mode: none to use pre-built custom binary
- Build custom-gcl and install as /usr/local/bin/golangci-lint
- Action now uses our custom binary with lintroller plugin

## why
- golangci-lint-action provides valuable features (annotations, caching, PR comments)
- install-mode: none allows using custom binary while keeping action benefits
- More maintainable than reimplementing action's functionality manually
- Leverages action's integration with GitHub's UI and workflows

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* docs: add comprehensive comments explaining custom linter plugin system

## what
- Added detailed comments to .custom-gcl.yml explaining plugin build process
- Added comments to .golangci.yml explaining custom linter configuration
- Added extensive inline comments to codeql.yml workflow explaining each step
- Documented how to add multiple custom linters to the system

## why
- Plugin system is complex and not immediately obvious
- Comments clarify that multiple custom linters compile into single binary
- Explains why we install golangci-lint v2 (for the build tool, not linters)
- Documents the relationship between .custom-gcl.yml and .golangci.yml
- Makes it clear how install-mode: none allows using custom binary with action

## references
- Addresses confusion about supporting multiple custom linters
- Clarifies build process and integration with golangci-lint-action
- Documents SARIF integration for GitHub Advanced Security

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* docs: expand lintroller README with module plugin integration details

## what
- Added comprehensive "How Module Plugins Work" section to README
- Documented single custom binary approach (not dynamic loading)
- Explained relationship between .custom-gcl.yml and .golangci.yml
- Added step-by-step guide for adding multiple custom linters
- Documented CI/CD integration with golangci-lint-action
- Clarified build process and install-mode: none usage

## why
- Module plugin system is non-obvious and differs from traditional .so plugins
- Users need to understand all plugins compile into single binary
- Important to document why we install golangci-lint v2 (build tool)
- Shows how to scale to multiple custom linters
- Explains SARIF integration and GitHub Security benefits

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: address CodeRabbit review comments

- Add periods to inline comments in test file (godot linter)
- Pin golangci-lint-action version to v2.5.0 to match built binary

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: update golangci-lint args to use v2 output format syntax

Change from `--out-format=sarif:file.sarif` (v1 syntax) to
`--output.sarif.path=file.sarif` (v2 syntax).

This fixes the CI error: "unknown flag: --out-format"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: ensure lintroller binary has execute permissions after build

Add explicit chmod +x after go build to ensure the binary is executable
on all platforms, particularly in CI environments.

This fixes the pre-commit error: "Permission denied" when running lintroller

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: update lintroller build path to use cmd/lintroller subdirectory

The lintroller main package is in cmd/lintroller/, not the root.
This fixes the build to create a proper executable instead of an archive.

Also added:
- Explicit chmod +x after build for CI compatibility
- Verification that binary is executable after build
- Updated dependencies to include cmd/lintroller/*.go

This fixes: 'Permission denied' and 'syntax error' when running lintroller

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: exclude testdata directories from lintroller checks

The lintroller/testdata contains intentional violations for testing.
Exclude all testdata directories using 'go list' with grep filter.

This fixes: lintroller reporting false positives on test fixtures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: replace os.Setenv/os.MkdirTemp with t.Setenv/t.TempDir in test files

Replace os.Setenv with t.Setenv in test files for automatic cleanup:
- pkg/config/load_test.go: 8 violations fixed
- pkg/list/list_vendor_test.go: 1 os.MkdirTemp violation fixed
- pkg/utils/yaml_func_exec_test.go: 3 violations fixed

This ensures environment variables and temp directories are automatically
cleaned up after tests without needing manual defer statements.

Fixes lintroller violations caught by custom linting rules.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* [autofix.ci] apply automated fixes

* fix: address CodeRabbit review comments and CI failures

- Fix undefined err in pkg/list/list_vendor_test.go by declaring err variable
- Update setupTestFiles to use t.TempDir() instead of os.MkdirTemp
- Change issues-exit-code from 0 to 1 in golangci-lint workflow
- Add continue-on-error and if: always() to ensure SARIF upload even on failures

This ensures linting violations properly fail CI while still uploading
SARIF results for GitHub Advanced Security integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* test: enhance Windows case-insensitive test with sentinel verification

Add sentinel file creation and verification to ensure the config import
is actually skipped (not just that it returns no error). This provides
stronger validation that the case-insensitive path matching works correctly
on Windows.

Addresses CodeRabbit review comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* ci: pin golangci-lint-action to v8.0.0

Pin the action version to match best practices and ensure
reproducible builds. Addresses CodeRabbit review comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: preserve test mode detection in TestFilterAndListVendor

When changing from os.MkdirTemp to t.TempDir(), the directory name
no longer contained 'atmos-test-vendor', which broke the test mode
detection in getVendorInfos. Fixed by creating an intermediate
directory with the expected name pattern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* feat: add custom-gcl Makefile target and update pre-commit hook

Add a Makefile target to build the custom golangci-lint binary
(custom-gcl) that includes the lintroller plugin. Update the
pre-commit hook to build and use this custom binary instead of
the system golangci-lint, ensuring lintroller rules are enforced
during pre-commit checks.

Changes:
- Add custom-gcl target to Makefile that builds the binary if missing
- Update lint target to depend on custom-gcl and use ./custom-gcl
- Update pre-commit golangci-lint hook to build and use custom-gcl

This ensures developers have the same linting experience locally
as in CI, catching violations before they're pushed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: skip lintroller in pre-commit CI and ensure module ready

Fix CI failures by:
1. Skip lintroller hook in pre-commit.yml since it already runs
   in codeql.yml via the custom golangci-lint binary
2. Run go mod tidy on lintroller module before building custom
   golangci-lint to ensure dependencies are ready

This ensures:
- No duplicate linting runs between pre-commit and codeql workflows
- Custom binary build succeeds by having clean module state
- Lintroller enforcement happens once in codeql.yml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: address CodeRabbit review comments

Address remaining CodeRabbit review feedback:

1. Fix lintroller description in .golangci.yml
   - Changed from 't.TempDir checks' to 'os.MkdirTemp checks'
   - Accurately reflects the actual rule (os-mkdirtemp-in-test)

2. Remove stale-binary guard in Makefile custom-gcl target
   - Removed 'if [ ! -f ./custom-gcl ]' guard that prevented rebuilds
   - Added .custom-gcl.yml as a dependency
   - Ensures binary is rebuilt when inputs change

Note: The codeql.yml comment about || true was already addressed
in commit f9010b9 which added continue-on-error and if: always().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: remove duplicate Windows tests and fix golangci-lint CI

Fix two critical CI issues:

1. Windows test compilation failure
   - Remove duplicate TestShouldExcludePathForTesting_WindowsCaseInsensitive
   - Remove duplicate TestMergeDefaultImports_WindowsCaseInsensitive
   - These tests exist in load_windows_test.go with proper build constraints
   - Having them in both files caused redeclaration errors on Windows

2. golangci-lint action not using custom binary
   - Replace golangci-lint-action usage with direct binary execution
   - The action was finding system binary even with install-mode: none
   - Now directly runs: golangci-lint run with custom binary
   - Copy custom-gcl to both /usr/local/bin and ~/go/bin for coverage

This ensures:
- Windows tests compile without redeclaration errors
- lintroller plugin is available during CI linting
- Custom binary is used instead of system binary

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: restore golangci-lint-action and fix PATH properly

Revert the mistake of replacing the golangci-lint-action with raw
commands. The action provides critical features like PR annotations,
caching, and GitHub UI integration.

The real fix is to move the system binary out of the way BEFORE
copying our custom binary:
- mv ~/go/bin/golangci-lint ~/go/bin/golangci-lint.system
- cp ./custom-gcl ~/go/bin/golangci-lint

This ensures when the action runs with install-mode: none, it finds
our custom binary with the lintroller plugin in PATH.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: remove unused imports in load_test.go

Remove runtime and strings imports that were left over after
removing the Windows-specific test functions. These imports are
not needed in load_test.go since the Windows tests are now only
in load_windows_test.go.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: add error handling to golangci-lint build and remove continue-on-error

Fix two critical issues in the golangci-lint workflow:

1. Add comprehensive error checking to custom binary build:
   - Set 'set -e' to exit on any error
   - Check if 'golangci-lint custom' succeeds
   - Verify ./custom-gcl exists and is executable
   - Check mv and cp commands succeed with error messages
   - Fail fast with clear error messages if any step fails

2. Remove 'continue-on-error: true' from golangci-lint step:
   - Step will now FAIL the job if linting issues are found
   - SARIF upload step keeps 'if: always()' to upload even on failure
   - Provides proper enforcement while preserving SARIF results

This ensures:
- Workflow stops immediately if custom binary build fails
- No stale or missing binaries are used
- Linting failures properly fail the CI check
- SARIF results are still uploaded for GitHub Security

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* fix: match main branch behavior with issues-exit-code=0

Revert to main branch behavior where golangci-lint uses
--issues-exit-code=0 to always succeed and upload SARIF.

Main branch pattern:
- golangci-lint doesn't fail the CI job on linting issues
- SARIF results are uploaded to CodeQL/Security tab for visibility
- This allows the workflow to complete and show findings without blocking

The enforcement happens via:
- Pre-commit hooks (make lintroller) - now properly enforced without || true
- PR annotations from golangci-lint action
- CodeQL Security tab visibility via SARIF

This matches the existing CI pattern established in main branch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) size/xs Extra small size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants