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.
I was somewhat confused at first that all the modules in testdata have essentially fake Dir - if each dir was otherwise terraform inited 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.tfBefore
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
%sinstead of%q) - let me know if you prefer either. My preference for%qwas primarily driven by making empty name and other short names with just special characters more visible and obvious.