-
Notifications
You must be signed in to change notification settings - Fork 139
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
Confusing 'conditional expression without else clause' error with a yaml error before the if statement #496
Comments
Thanks for the simple example (reproduced in Playground). Wow, this is an unfortunate error message. TL;DR — at this point changing this behavior may be very hard. So, under the covers, In Starlark, the Some inside baseball: For example, this template gets compiled to: ...
__ytt_tpl2_start_node(6)
__ytt_tpl2_set_node(6, ("--webhook-port={}".format(webhook_port))
if image_pull_secrets_enabled:
__ytt_tpl2_start_node(7)
__ytt_tpl2_start_node(8)
__ytt_tpl2_start_node(9)
__ytt_tpl2_start_node(10)
__ytt_tpl2_start_node(11)
__ytt_tpl2_set_node(11, (image_pull_secrets_name))
end
__ytt_tpl2_start_node(12)
... (compiled template listings are included in the It's subtle, but given that there's one fewer parens on that second line of the listing and that Starlark in i.e. the I absolutely get that this is not how it reads to the eye within the template. So, I want to chew on this for a bit. As it stands, tho, I'm currently not bullish it's feasible to fix this error message. 😬 |
Thanks for the detailed reply 👍🏼 |
@pivotaljohn hmm, i wonder if we can run set node lines through its own ast parse... should that always succeed, i think so... in theory it should be self-contained (though symbols wont be resolved). |
🤔 nice. Does this hold for when we're replacing too? I think so... hmmmmm. |
no idea... |
No question this would be great to be able to provide a better experience, here. Next step is to explore either the option @cppforlife noted, above, and/or other ways to catch this situation so we can then provide a better message to the user. |
This is related to other less-than-great UX in templates:
src: https://kubernetes.slack.com/archives/CH8KCCKA5/p1649264496571349 |
What steps did you take:
I attempted to template a yaml file with some invalid
yttt
syntax:What happened:
An error that suggested that my if block was missing an else clause was thrown:
What did you expect:
Ideally, an error that would point out the line that has the error.
Failing that, an error that would suggest that the issue might be before the if block as the current error seems to strongly suggest that the issue is with the if block.
Environment:
v0.36.0
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
The text was updated successfully, but these errors were encountered: