-
Notifications
You must be signed in to change notification settings - Fork 602
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
Panic in hclwrite parser: didn't find any token of type TokenIdent #327
Comments
Thanks to @pdecat in apparentlymart/terraform-clean-syntax#2, we have the following small reproduction case:
|
Noticed #328 is merged was included in records = ["${aws_elasticache_cluster.mgmt.cache_nodes.0.address}"] |
Hi @roni-frantchi, Do you see the same crash if that's written in the non-legacy syntax |
Thanks for the prompt reply @apparentlymart .
Not quite the same error originally posted on this issue, but one I had thought was similar. Making an edit and using |
Thanks @roni-frantchi! It sounds like there are still some similar cases like the ones I previously fixed, where the main HCL parser isn't producing accurate enough source location information. I won't be able to prioritize further work on this right now because my focus is elsewhere, but I'll keep it on my list to take a look at next time I have some HCL cycles, if someone else doesn't get there before me. |
Hi @apparentlymart |
This should be fixed by #369. |
Thanks @alisdair - confirmed it's working for us |
Originally reported over in apparentlymart/terraform-clean-syntax#3 by @mattsawyer77.
On certain input, it seems that the analysis of traversals in expressions fails and produces a panic:
It looks like the relevant bit of code is here-ish:
hcl/hclwrite/parser.go
Lines 391 to 400 in 7f9aa84
This codepath is assuming that any traversal step marked by the main parser as being a root (the beginning of a traversal) or an attribute (something that comes after a
.
) will contain an identifier in it. On the surface that seems like a reasonable assumption, but apparently there is at least one exceptional case where that isn't true.The text was updated successfully, but these errors were encountered: