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
Plan unable to execute with Space in key=value --> key = value #30600
Comments
Thanks for this issue report. I'm going to float it past the docs team to see what they think. |
That would be wonderful. Thank you @crw |
The error message here is certainly confusing. It may be possible to detect the case in which there are spaces around the "=" and return a better error message. In any case this could do with better documentation. Leaving this open in case we fix the error message. |
If we do ultimately elect to change the behavior here to treat the spaces differently, I agree with @kmoe that it would be better to still return an error but to make that error more specific, rather than to silently allow it. Although silently allowing a space before the equals sign would not really hurt too much, because a space is never valid to appear in a variable name anyway, a space after the equals sign should always be taken literally because it is valid for a string value to start with a space, even though I would agree that it's not typical for a string value to start with a space. Given that, I think it's better to be consistent and treat a space before the equals sign as if it were a part of the variable name, and then treat it as an error because there is no variable of that name (and such a name would be impossible, due to the identifier rules). |
@apparentlymart I agree. Since nobody can/ "should" make such variable, document on variable character constraints should mention spaces not allowed. |
Hi all! I put up a PR to help address this issue in the docs. It feels like a simple "Terraform errors if you add spaces" should suffice, but I'm happy to edit if you think it needs more context or detail. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Putting a space between variable name and value causes a error message
while
Executes perfectly.
Terraform Version
Terraform Configuration Files
Expected Behavior
on
Please notice the "space" before and after "="
The plan should've executed successfully. Which it does, when spaces are removed (find the attached image and code).
Actual Behavior
The code spews confusing error , the one stated at the start of this post.
This error should be prompting to remove spaces instead of
│ Error: Value for undeclared variable
Steps to Reproduce
Just regular terraform workflow.
It could be any code with spaces around "=" as you assign -var values.
Additional Context
Since variable is declared. Values are ok. It's just a small-innocent mistake(?) at user's part.
I don't know if others have reported this issue, (I could be naive and posting it repeat)
Or if it qualifies as Documentation/Feature request, So here I am.
Seems like it isn't the bug/issue, from the issue#11 as it's closed.
but documents still lack and could potentially lead a beginner astray.
Please Consider updating/mentioning this into the documentation, if this issue can't be helped/resolved.
References
Input Variable Documentation
Variables Documentation
tf-helper issue #11
The text was updated successfully, but these errors were encountered: