You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, poking around in your settings system I noticed that the templates, both on the input from the user-data.toml and to the output in the templates, you use kebab-case, but in rust you use snake_case (few programming languages allow you to use kebab-case, I guess).
This took me an embarrassingly long time to figure out (I just assumed that since it was decoded into rust structs with snake_case, that the templating would use snake_case also).
Ultimately, what was not ergonomic in this was that I got no real error when trying to access template variables that does not exist and is not set. You do take great care to validate it in Rust, etc - perhaps there is a way to make sure that when accessing variables in the templating stage, that you check that the variable exists? Would have saved me a lot of time!
The text was updated successfully, but these errors were encountered:
mikn
changed the title
Usage of both kebab-case and snake_case i n templating is very confusing
Usage of both kebab-case and snake_case in templating is confusing
Dec 21, 2024
mikn
changed the title
Usage of both kebab-case and snake_case in templating is confusing
No error messages when accessing undefined variables in config templating
Dec 21, 2024
The template renderer is supposed to throw an error if we attempt to use a variable which isn't defined. We enable strict mode when constructing the template registry (relevant docs).
I wonder if we are rendering templates via a codepath that doesn't use these registry settings, or if these errors are not surfaced in a way that makes problems clear.
Yep, we don't use that codepath when we render template files in Bottlerocket.
Here's where we render templates, and that calls this function which does not use the registry code I linked above.
Phooey, I almost certainly introduced this regression when I last worked on schnauzer.
We can re-enable strict mode for these renderings, but we'll need to be very cautious in doing so -- it's a backwards incompatible change for core-kit. Existing templates which successfully render today could very well stop.
So, poking around in your settings system I noticed that the templates, both on the input from the user-data.toml and to the output in the templates, you use kebab-case, but in rust you use snake_case (few programming languages allow you to use kebab-case, I guess).
This took me an embarrassingly long time to figure out (I just assumed that since it was decoded into rust structs with snake_case, that the templating would use snake_case also).
Ultimately, what was not ergonomic in this was that I got no real error when trying to access template variables that does not exist and is not set. You do take great care to validate it in Rust, etc - perhaps there is a way to make sure that when accessing variables in the templating stage, that you check that the variable exists? Would have saved me a lot of time!
The text was updated successfully, but these errors were encountered: