Skip to content
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

More precise error message for undefined template variables #60

Open
SimonDreher opened this issue Nov 30, 2022 · 1 comment · May be fixed by #61
Open

More precise error message for undefined template variables #60

SimonDreher opened this issue Nov 30, 2022 · 1 comment · May be fixed by #61

Comments

@SimonDreher
Copy link

SimonDreher commented Nov 30, 2022

Is your feature request related to a problem? Please describe.
If I reference an undeclared variable in my template, the error message is like template 'example.filef' uses variables with undefined value on line 36 (line number is based on the rendered output and might not be accurate).

The line number is partially helpful, since it is only roughly in that line in the source file.

Describe the solution you'd like
In many cases it would help me if the variable that is missing would be mentioned.

For example the error message could look like template 'example.filef' uses variable '.Inventory.foo.bar' with undefined value on line 36 (line number is based on the rendered output and might not be accurate)

@lukasjarosch
Copy link
Owner

I absolutely feel your pain, but this might be a tricky one.
The way it is currently handled is that the template package will replace any undefined variable with <no value>.
The undefined value detection leverages that behaviour to detect that there is some undefined variable, but not which one.

I'll try to figure out a viable solution for this 😃

@lukasjarosch lukasjarosch self-assigned this Nov 30, 2022
@lukasjarosch lukasjarosch added this to the Initial Release milestone Nov 30, 2022
@lukasjarosch lukasjarosch linked a pull request Nov 30, 2022 that will close this issue
@lukasjarosch lukasjarosch changed the title More precise error message on More precise error message for undefined template variables Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants