Skip to content

feat: show Terraform error details #6643

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 3 commits into from
Mar 20, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Mar 17, 2023

Resolves: #6453

This PR enables Terraform diagnostics details in the site view and CLI. Unfortunately, the original formatter is in the internal package, so I had to implement a similar one.

Screenshot 2023-03-17 at 12 43 12

Screenshot 2023-03-17 at 12 42 10

@mtojek mtojek self-assigned this Mar 17, 2023
@mtojek mtojek marked this pull request as ready for review March 17, 2023 12:13
@mtojek mtojek requested review from bpmct and mafredri March 17, 2023 12:13
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Looks good in general, but I couldn't really see how/if the existing internal formatting is used at all any longer, in which case we may lose error detail?

@@ -509,7 +512,7 @@ func convertTerraformLogLevel(logLevel string, sink logSink) proto.LogLevel {
return proto.LogLevel_DEBUG
case "info":
return proto.LogLevel_INFO
case "warn":
case "warn", "warning":
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need both?

Copy link
Member Author

Choose a reason for hiding this comment

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

I spotted in the original Terraform code that it has references to "warning". Maybe some Terraform versions or plugins use a different label?

for _, value := range values {
_, _ = fmt.Fprintf(buf, " │ %s %s\n", value.Traversal, value.Statement)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

It seemed like the original (internal) code is slightly more complex, do we lose any details in error output or are they surfaced some other way? It looked like function calls/args were handled in internal, but not here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, as these are not exposed by terraform-json. I think that we can live without those until any user requests them.

@mtojek mtojek enabled auto-merge (squash) March 20, 2023 13:19
@mtojek mtojek merged commit de83723 into coder:main Mar 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform errors don't give line numbers, making it hard to debug
3 participants