Skip to content

Conversation

@denis256
Copy link
Member

@denis256 denis256 commented Oct 29, 2025

Description

Before this fix:

image

After this fix:

image

Fixes #4983.

TODOs

Read the Gruntwork contribution guidelines.

  • I authored this code entirely myself
  • I am submitting code based on open source software (e.g. MIT, MPL-2.0, Apache)]
  • I am adding or upgrading a dependency or adapted code and confirm it has a compatible open source license
  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection and error reporting for deprecated configuration syntax (earlier, clearer errors for exposed includes).
    • Better handling of include-only/no-settings configs when parse-error suppression is enabled to avoid fatal failures.
    • Clarified include-block deprecation message for unlabeled includes.
  • Tests

    • Added regression tests covering deprecated inputs in exposed includes and run-all scenarios with generate/expose behavior.

@vercel
Copy link

vercel bot commented Oct 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
terragrunt-docs Ready Ready Preview Comment Oct 30, 2025 2:59pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

📝 Walkthrough

Walkthrough

Early deprecation detection was added to partial config parsing to fail fast on deprecated syntax in included configs. Discovery now treats include-only/no-settings parse failures as non-fatal when suppression is enabled. Additional test fixtures and regression tests were added, and minor Path -> Path() refactors applied.

Changes

Cohort / File(s) Summary
Early deprecation detection in partial parsing
config/config_partial.go
Invoke DetectDeprecatedConfigurations early in PartialParseConfig and return its error immediately to block deprecated syntax before further parsing.
Discovery error handling enhancements
internal/discovery/discovery.go
Add containsNoSettingsError() helper; on PartialParse errors, if suppression is enabled and error indicates no Terragrunt settings, treat as non-fatal (log debug and skip) and improve debug/error logging. Also add nil-check in DiscoverDependencies.
Path method refactoring
internal/runner/runnerpool/controller.go
Replace direct Path field accesses with Path() method calls in logs, lookups, and result handling.
Deprecated inputs test fixture
test/fixtures/parsing/exposed-include-with-deprecated-inputs/*
\test/fixtures/parsing/exposed-include-with-deprecated-inputs/root.hcl`, `.../compcommon.hcl`, `.../child/terragrunt.hcl`, `.../dep/terragrunt.hcl``
Add fixture exercising exposed include with deprecated dependency.*.inputs.* usage and a mock dependency.
Run-all with generate test fixture
test/fixtures/regressions/parsing-run-all-with-generate/*
\root.hcl`, `services/test1/{main.tf, terragrunt.hcl}`, `services-info/{main.tf, terragrunt.hcl}``
Add fixtures for run --all scenarios with generate blocks, provider generation, service module outputs, and a services-info consumer.
Integration parse test update
test/integration_parse_test.go
Mark fixtures/parsing/exposed-include-with-deprecated-inputs/compcommon.hcl as known bad (skip full parse).
Regression tests
test/integration_regressions_test.go
Add tests: TestExposedIncludeWithDeprecatedInputsSyntax, TestRunAllWithGenerateAndExpose, and TestRunAllWithGenerateAndExpose_WithProviderCacheAndExcludeExternal.
Strict mode test message update
test/integration_strict_test.go
Update expected error message for bare include strict-mode tests to deprecation wording for unlabeled include blocks.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PartialParseConfig
    participant DetectDeprecated
    participant Parser

    Client->>PartialParseConfig: Request partial parse (included config)
    PartialParseConfig->>DetectDeprecated: Check for deprecated syntax
    alt deprecated syntax found
        DetectDeprecated-->>PartialParseConfig: Return deprecation error
        PartialParseConfig-->>Client: Return error (fail fast)
    else no deprecated syntax
        DetectDeprecated-->>PartialParseConfig: OK
        PartialParseConfig->>Parser: Continue parsing/decoding
        Parser-->>Client: Return partial config
    end
Loading
sequenceDiagram
    participant Discovery
    participant PartialParse
    participant ErrorChecker
    participant Storage

    Discovery->>PartialParse: PartialParse included file
    alt PartialParse returns error
        PartialParse-->>ErrorChecker: Error
        ErrorChecker->>ErrorChecker: containsNoSettingsError(err)?
        alt suppression enabled && no-settings error
            ErrorChecker->>Discovery: Log debug, treat as non-fatal
            Discovery->>Storage: Do not store partial config (skip)
            Discovery-->>Client: Continue discovery without this include
        else
            ErrorChecker-->>Discovery: Propagate error
        end
    else success
        PartialParse-->>Discovery: Store partial config
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay extra attention to:
    • The early call to DetectDeprecatedConfigurations in config/config_partial.go (ensure it doesn't change intended parsing order for other checks).
    • containsNoSettingsError() matching/unwrapping logic and the conditional suppression path in internal/discovery/discovery.go.
    • All places where .Path was replaced with .Path() in internal/runner/runnerpool/controller.go to ensure no behavioral changes in map keys or logging formats.
    • Added test fixtures and new tests for correctness and expected failure modes.

Possibly related PRs

Suggested reviewers

  • yhakbar
  • levkohimins
  • wakeful

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "bug: discovery parsing errors handling" directly and specifically summarizes the main change focus, which is improving error handling and logging in the discovery parsing process. The title accurately reflects the core improvements to error detection and reporting mechanisms, particularly addressing the issue of cryptic error messages and formatting artifacts in discovery logs. The title is concise, specific, and clearly communicates the primary objective without vague terminology.
Linked Issues Check ✅ Passed The changes directly address the primary objective stated in issue #4983: resolving the unrecoverable parse error "Could not find Terragrunt configuration settings" and eliminating the cryptic logging artifact "Errors: %!w(...)". The code modifications in config/config_partial.go add early deprecated configuration detection, internal/discovery/discovery.go implements graceful skipping of include-only configs and fixes error formatting in logging, and internal/runner/runnerpool/controller.go corrects log output formatting. The addition of regression tests validates that deprecated syntax detection and run-all scenarios work correctly without parsing artifacts.
Out of Scope Changes Check ✅ Passed All code changes are directly aligned with the stated PR objectives and linked issue #4983. The modifications address: improved detection of legacy fields during HCL parsing, enhanced discovery error handling with better logging (eliminating %w formatting artifacts), correct log formatting in the runner pool, and comprehensive test coverage for the new behaviors. The test fixtures and regression tests are specifically designed to validate the fixes and prevent future regressions in these areas.
Description Check ✅ Passed The pull request description includes all required sections from the template: a substantive Description section with clear bullet points and an issue reference (Fixes #4983), a completed TODOs checklist with items marked as done, and Release Notes and Migration Guide sections. While the Release Notes and Migration Guide contain placeholder text rather than fully detailed content, the description provides sufficient context about the changes and demonstrates the fix through before/after screenshots. The description is mostly complete with all major structural elements present.
✨ 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 4983-parse-error

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6c6911 and cdc4e56.

📒 Files selected for processing (1)
  • internal/discovery/discovery.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/discovery/discovery.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). (19)
  • GitHub Check: build_no_proxy / Build (linux/arm64)
  • GitHub Check: build_no_proxy / Build (linux/386)
  • GitHub Check: build / Build (linux/arm64)
  • GitHub Check: build / Build (windows/386)
  • GitHub Check: build_no_proxy / Build (windows/386)
  • GitHub Check: build_no_proxy / Build (windows/amd64)
  • GitHub Check: build / Build (linux/amd64)
  • GitHub Check: build_no_proxy / Build (darwin/arm64)
  • GitHub Check: build_no_proxy / Build (darwin/amd64)
  • GitHub Check: build / Build (windows/amd64)
  • GitHub Check: build_no_proxy / Build (linux/amd64)
  • GitHub Check: build / Build (linux/386)
  • GitHub Check: build / Build (darwin/arm64)
  • GitHub Check: build / Build (darwin/amd64)
  • GitHub Check: base_tests / Test (macos)
  • GitHub Check: base_tests / Test (ubuntu)
  • GitHub Check: Pull Request has non-contributor approval
  • GitHub Check: build-and-test
  • GitHub Check: Pull Request has non-contributor approval

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.

@denis256 denis256 marked this pull request as ready for review October 30, 2025 11:14
@denis256 denis256 requested a review from yhakbar as a code owner October 30, 2025 11:14
yhakbar
yhakbar previously approved these changes Oct 30, 2025
if suppressParseErrors && containsNoSettingsError(err) {
l.Debugf("Skipping include-only config during discovery: %s", parseOpts.TerragruntConfigPath)

// Store an empty partial config to avoid nil dereferences in subsequent dependency discovery
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is odd to me. Why don't we just nil check later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unrecoverable parse error for ./terragrunt.hcl: Could not find Terragrunt configuration settings in ./terragrunt.hcl

3 participants