-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
packer validate .
outputs same error message multiple times for unsupported block types
#13241
Comments
I would like to deal with this issue if it is in fact a bug. |
Thanks @gstvcruz for the report I just tried on my local machine seems like you're right. it does look like a bug. If you want to take a bite at it, be my guest! We warmly welcome contribution :) |
When parsing a packer template, there are four stages: decoding the required plugins block, decoding input variables, decoding data sources, and parsing local variable blocks. Each stage processes the file's body content to validate the arguments and block types for every block in the file. As a result, the same error message may be appended to the output at each stage for unsupported block types. I'm new to Go and have never contributed to an open-source project before, especially one of this size. However, I think I'm onto something. I suppose it’s just a matter of avoiding unnecessary appendages—perhaps by checking the already appended message summary against the summary of the message to be appended? Another simpler approach would be to just remove duplicates from the output, which comes from a slice of error messages. |
It seems I've fixed it! Every stage was checking for invalid arguments or unsupported block types using the same function, so I refactored it into a |
Community Note
Overview of the Issue
packer validate .
outputs the same error message exactly four times for each unsupported root block type found per packer template.Reproduction Steps
Introduce any amount of unsupported root block types in any packer template. Nested blocks aren't affected.
Packer version
v1.11.2
Simplified Packer Template
e.g., src instead of source, but it happens for any unsupported block type.
packer {
...
}
src "docker" "ubuntu" {
...
}
build {
...
}
Operating system and Environment details
Ubuntu 24.04 x86_64
The text was updated successfully, but these errors were encountered: