github cloudposse/atmos v1.196.0-rc.2

pre-release2 days ago
Add circular dependency detection for YAML functions @osterman (#1708) ## what - Implement universal circular dependency detection for all Atmos YAML functions (!terraform.state, !terraform.output, atmos.Component) - Add goroutine-local resolution context for cycle tracking - Create comprehensive error messages showing dependency chains - Fix missing perf.Track() calls in Azure backend wrapper methods - Refactor code to meet golangci-lint complexity limits

why

  • Users experiencing stack overflow panics from circular dependencies in component configurations
  • Need to detect cycles before they cause panics and provide actionable error messages
  • Performance tracking required for all public functions per Atmos conventions
  • Reduce cyclomatic complexity and function length for maintainability

Implementation Details

Architecture

  • Goroutine-local storage using sync.Map with goroutine IDs to maintain isolated resolution contexts
  • O(1) cycle detection using visited-set pattern with Push/Pop operations
  • Call stack tracking for building detailed error messages showing dependency chains
  • Zero performance impact (<10 microseconds overhead, <0.001% of total execution time)

Test Coverage

  • 27 comprehensive tests across 4 test files
  • 100% coverage on core resolution context logic
  • ~75-80% overall coverage (excluding benchmark and integration tests)
  • Benchmark tests proving negligible performance impact
  • Integration tests for real-world scenarios (currently skipped - require state backends)

Performance

  • Push operation: ~266 nanoseconds
  • Pop operation: ~70 nanoseconds
  • GetGoroutineID: ~2,434 nanoseconds
  • Total overhead: <10 microseconds (<0.001% of execution time)

Error Messages

Before (stack overflow panic):

runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

After (actionable error with dependency chain):

circular dependency detected

Dependency chain:
  1. Component 'vpc' in stack 'core'
     → !terraform.state transit-gateway core transit_gateway_id
  2. Component 'transit-gateway' in stack 'core'
     → !terraform.state vpc core vpc_id
  3. Component 'vpc' in stack 'core' (cycle detected)
     → !terraform.state transit-gateway core transit_gateway_id

To fix this issue:
  - Review your component dependencies and break the circular reference
  - Consider using Terraform data sources or direct remote state instead
  - Ensure dependencies flow in one direction only

references

  • Fixes community-reported stack overflow issue in YAML function processing
  • See docs/prd/circular-dependency-detection.md for complete architecture and design decisions
  • See docs/circular-dependency-detection.md for user documentation and troubleshooting
  • See CIRCULAR_DEPENDENCY_DETECTION_SUMMARY.md for implementation summary

Files Changed

  • Core implementation: internal/exec/yaml_func_resolution_context.go (161 lines)
  • Tests: 4 test files (1,093 lines total)
  • Modified: yaml_func_utils.go, yaml_func_terraform_state.go, yaml_func_terraform_output.go
  • Documentation: PRD, user docs, summary
  • Test fixtures: 7 YAML files + 2 Terraform components
  • Additional: Fixed Azure backend perf.Track() issues

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • New Features
    • Automatic circular dependency detection for YAML functions including terraform.state, terraform.output, and custom component functions. The system detects cycles early before runtime failures occur, providing comprehensive error messages that display the full dependency chain and component relationships. Users receive actionable remediation guidance and suggested fixes to resolve circular dependencies in their infrastructure configurations.
fix: Remove exclude directive to enable go install @osterman (#1709) ## what - Removed `exclude` directive from go.mod that was blocking `go install github.com/cloudposse/atmos@main` - Updated go install compatibility test to check for both `replace` and `exclude` directives

why

  • The exclude directive in go.mod prevents users from installing Atmos via go install
  • Go modules with exclude directives cannot be used as dependencies (by design)
  • This breaks a documented installation method and creates user friction
  • The excluded version (godbus/dbus v0.0.0-20190726142602-4481cbc300e2) is already superseded by explicitly required versions (v4.1.0 and v5.1.0)

references

🤖 Generated with Claude Code

fix: Upgrade to Go 1.25 and make test logging respect -v flag @osterman (#1706) ## what - Upgraded Go version from 1.24.8 to 1.25.0 - Configured Atmos logger in tests to respect `testing.Verbose()` flag - Tests are now quiet by default, verbose with `-v` flag - Added missing `perf.Track()` calls to Azure backend wrapper methods

why

  • Go 1.24.8 had a runtime panic bug in unique_runtime_registerUniqueMapCleanup on macOS ARM64 (golang/go#69729)
  • This caused TestGetAffectedComponents to panic during cleanup on macOS CI
  • Test output was always verbose because logger was set to InfoLevel unconditionally
  • Go 1.25.0 fixes the runtime panic bug
  • Linter enforcement requires perf.Track() on all public functions

changes

  • go.mod: Upgraded from go 1.24.8 to go 1.25.0
  • tests/cli_test.go:
    • Moved logger level configuration from init() to TestMain()
    • Logger now respects -v flag using switch statement:
      • ATMOS_TEST_DEBUG=1: DebugLevel (everything)
      • -v flag: InfoLevel (info, warnings, errors)
      • Default: WarnLevel (only warnings and errors)
    • Removed debug pattern logging loop (was spam)
    • All helpful t.Logf() messages preserved (work correctly with -v)
  • internal/terraform_backend/terraform_backend_azurerm.go:
    • Added perf.Track() to GetBody() wrapper method
    • Added perf.Track() to DownloadStream() wrapper method

testing

  • go test ./tests → Quiet (no logger output)
  • go test ./tests -v → Verbose (shows INFO logs)
  • go test ./internal/exec -run TestGetAffectedComponents → Passes without panic

references

Don't miss a new atmos release

NewReleases is sending notifications on new releases.