-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
fix: validate implied provider names in submodules #31573
Conversation
{ | ||
"Key": "test", | ||
"Source": "./sub", | ||
"Dir": "testdata/invalid-names-in-submodules/sub" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was somewhat confused at first that all the modules in testdata
have essentially fake Dir
- if each dir was otherwise terraform init
ed directly, there wouldn't be testdata/invalid-names-in-submodules
but only the last part (sub
).
I'm not sure if that's intentional or not, just something I wanted to point out here.
Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch. |
@jbardin Is it worth back-porting this bug fix? Not sure what your convention is around this and how do you do it. |
d'oh, I forgot to check for a backport label, but yes it's a simple fix causing crashes in the release, so that should be OK. if you could manually backport it to v1.2 that would be great! In the future, if you apply a backport label before merging, the backport assistant will cherrypick the commits into a new PR for you. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #31572
Example config
(which triggers the bug)
./main.tf
./sub/main.tf
Before
After
Notes
There are also cases which may produce an extra error - assuming that the provider name is also invalid for HCL:
I didn't spend much time on deduplicating it though as I'd expect/hope this is generally an error people will see quite rarely.
I chose to quote the original provider name in the error message, although the other existing diagnostic doesn't do that (uses
%s
instead of%q
) - let me know if you prefer either. My preference for%q
was primarily driven by making empty name and other short names with just special characters more visible and obvious.