Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: skip validating unknown versions list#115

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 1 commit intomainfromethan/skip-validate
Oct 21, 2024

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedOct 21, 2024
edited
Loading

This fixes an error when setting theversions attribute of acoderd_template using a variable, e.g:

resource"coderd_template""dev" {versions=var.template_versions    [...]}variable"template_versions" {description="Versions of the Coder template."default=[    {      directory="modules/"      active=true      tf_vars= [          {              name="coder_instance"              value="prod"          }      ]    }  ]}

would return:

│ Error: Value Conversion Error││   with module.devcontainers.coderd_template.dev,│ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider│ developer:││ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom type that handles│ unknown values.││ Path:│ Target Type: []provider.TemplateVersion│ Suggested Type: basetypes.ListValue

This error was caused by attempting to validate the versions list without checking if the config value is unknown. Normally, this value should never be unknown, as it's required, but it looks like Terraform does a configuration validationbefore variables are populated, as well as after.

To confirm this is the correct solution, we see that all the default validators perform the same null & unknown checks, e.g:

func (vlengthBetweenValidator)ValidateString(ctx context.Context,request validator.StringRequest,response*validator.StringResponse) {ifrequest.ConfigValue.IsNull()||request.ConfigValue.IsUnknown() {return}...}

@ethanndicksonGraphite App
Copy link
MemberAuthor

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

Join@ethanndickson and the rest of your teammates onGraphiteGraphite

@ethanndicksonethanndickson marked this pull request as ready for reviewOctober 21, 2024 06:11
@ethanndicksonethanndickson merged commit269046e intomainOct 21, 2024
14 checks passed
@ethanndicksonethanndickson deleted the ethan/skip-validate branchOctober 21, 2024 06:13
@ethanndicksonethanndickson self-assigned thisOct 21, 2024
ethanndickson added a commit that referenced this pull requestOct 31, 2024
Same problem as seen in#115.This fixes a problem where having multiple template version namesmanually set using Terraform variables would always return a duplicatename error, as Terraform would mark the attribute, although it isrequired and already written in the config, as Unknown before callingour custom validator. This unknown value is only ever passed to thevalidator, never `Create` or `Update`.Knowing this, we see the same problem exists for all attributes we readin our custom validator. The only remaining one is `active`, where wecheck at least one version is marked as active. In this case, we alsoneed to skip validating `active` if any of the booleans are unknown.We previously didn't have any tests that explicitly used Terraformvariables, so this PR adds one, in case the behaviour of these variableset attributes is changed in the future.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@ethanndickson

[8]ページ先頭

©2009-2025 Movatter.jp