Skip to content

fix: skip validating unknown version names #123

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

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Oct 31, 2024

Same problem as seen in #115.

This fixes a problem where having multiple template version names manually set using Terraform variables would always return a duplicate name error, as Terraform would mark the attribute, although it is required and already written in the config, as Unknown before calling our custom validator. This unknown value is only ever passed to the validator, never Create or Update.

Knowing this, we see the same problem exists for all attributes we read in our custom validator. The only remaining one is active, where we check at least one version is marked as active. In this case, we also need to skip validating active if any of the booleans are unknown.

We previously didn't have any tests that explicitly used Terraform variables, so this PR adds one, in case the behaviour of these variable set attributes is changed in the future.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @ethanndickson and the rest of your teammates on Graphite Graphite

@ethanndickson ethanndickson marked this pull request as ready for review October 31, 2024 02:35
if version.Name.IsNull() {
continue
}
if _, ok := uniqueNames[version.Name.ValueString()]; ok {
Copy link
Member Author

@ethanndickson ethanndickson Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If two names were populated using Terraform variables, they'd be Unknown and ValueString would return the empty string for both, which would then lead to a false duplicate in the map.

@ethanndickson ethanndickson merged commit 9321b39 into main Oct 31, 2024
14 checks passed
@ethanndickson ethanndickson deleted the ethan/skip-names branch October 31, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants