-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: better errors reporting form autoincludes #5985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
800bbdd
bug: HCL parsing errors handling
denis256 b57157d
bug: handling of auto include parsing errors
denis256 690900f
chore: auto include fixes
denis256 d9497b4
chore: simplified parsing errors
denis256 974725b
chore: stack parsing fixes
denis256 d4b5ca3
chore: internal tests
denis256 64b10cc
chore: statck parsing fixes
denis256 e7974b4
chore: stack dependencies autoinclude
denis256 2e607a8
chore: internal test fix
denis256 3de9124
chore: internal test fix
denis256 99e65e5
chore: improved discovery errors
denis256 5c4aa49
Merge branch '5980-auto-include-parse-errors' of github.com:gruntwork…
denis256 b7dd23a
chore: fuzz test
denis256 a5c3a38
chore: fuzzy tests improvements
denis256 458941c
Merge branch 'main' into 5980-auto-include-parse-errors
denis256 4988363
chore: auto include fix
denis256 e08b089
chore: stacks simplification
denis256 ae8ed13
chore: simplified auto include errors
denis256 15e9793
Merge remote-tracking branch 'origin/main' into 5980-auto-include-par…
denis256 64a58f9
chore: PR comments
denis256 0ef28a9
Merge remote-tracking branch 'origin/main' into 5980-auto-include-par…
denis256 6369be8
chore: failing tests fixes
denis256 971c091
Merge branch 'main' into 5980-auto-include-parse-errors
denis256 b3106a6
chore: discovery helpers
denis256 0e16b31
chore: symlinks handling
denis256 ed623fe
chore: parser cleanup
denis256 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
internal/discovery/stack_dependency_expansion_error_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package discovery_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/gruntwork-io/terragrunt/internal/discovery" | ||
| "github.com/gruntwork-io/terragrunt/internal/hclparse" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // Direct typed-error contract test: StackDependencyExpansionError must carry the depPath and unwrap cleanly to the original parser error. | ||
| func TestStackDependencyExpansionError_Unwrap(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| innerErr := hclparse.MalformedDependencyError{ | ||
| FilePath: "/some/path/terragrunt.autoinclude.hcl", | ||
| Name: "vpc", | ||
| Reason: "missing config_path attribute", | ||
| } | ||
|
|
||
| wrapped := discovery.NewStackDependencyExpansionError("/path/to/dep", innerErr) | ||
| require.Error(t, wrapped) | ||
| assert.Contains(t, wrapped.Error(), "/path/to/dep") | ||
| assert.Contains(t, wrapped.Error(), "missing config_path") | ||
|
|
||
| // errors.As must reach both the wrapper and the underlying typed error. | ||
| var expansion discovery.StackDependencyExpansionError | ||
| require.ErrorAs(t, wrapped, &expansion) | ||
| assert.Equal(t, "/path/to/dep", expansion.DepPath) | ||
|
|
||
| var malformed hclparse.MalformedDependencyError | ||
| require.ErrorAs(t, wrapped, &malformed) | ||
| assert.Equal(t, "vpc", malformed.Name) | ||
|
|
||
| // errors.Is must reach the leaf via Unwrap chain. | ||
| require.ErrorIs(t, wrapped, innerErr) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: In situations like these, we can return the paths we were able to discover.