-
Notifications
You must be signed in to change notification settings - Fork 137
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
When struct keys are not strings, should error, not panic #764
Comments
This beheviour happens on words like: on, off, true, false used as yaml keys. |
@hmarko thanks for reporting this! Panicking is not great 😢 Treating To be able to use the key #@data/values
---
general:
notifications:
recipients:
- [email protected]
"on":
- any |
Thank you ! I think it worth taking care of it to prevent nasty panics from happening. tools like ytt should template this anyway (what will happen if I want to change true to false as per the yaml spec using ytt ?) |
I agree, the panic isn't right. However, I think the right behavior according to spec is to treat your data values like so: #@data/values
---
general:
notifications:
recipients:
- [email protected]
true: #! note the boolean
- any
I am not sure I follow you here. Can you expound and maybe provide an example? |
Ok, I think I got it now :-) |
@hmarko it's not you, this was a "good intention, bad impact" idea that we actually had intended to "fix". But that work has not yet been prioritized by the maintainers. See #407. What remains, tho, is the better handling. As @mamachanko noted above: panics are suitable for when something goes terribly wrong internally. When the problem arises directly from our inputs, we should error out gracefully with a helpful + actionable message. 👍🏻 I'm going to adjust this issue to capture that scope. |
When a non-string value has been provided for an key in a struct,
ytt
should report an errorrather than panic (see below).
👇🏻 original report 👇🏻
when using
on
as a key in yaml (see below example) ytt panics. changing it to anything else solves it (just change the on: to on1: for example)config.yaml:
data.yaml:
ytt panics with the following stack trace:
Environment:
ytt version 0.43.0
CentOS Linux release 7.8.2003 (Core)
The text was updated successfully, but these errors were encountered: