Skip to content
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

Undefined attribute in Attribute.Attributes is not detected during terraform validate #304

Closed
magodo opened this issue Apr 25, 2022 · 3 comments
Labels
bug Something isn't working upstream-terraform Issues that relate to Terraform CLI changes

Comments

@magodo
Copy link

magodo commented Apr 25, 2022

Module version

v0.6.1

Relevant provider source code

"http": {
	Description:         "Configuration for the HTTP authentication scheme",
	MarkdownDescription: "Configuration for the HTTP authentication scheme",
	Optional:            true,
	Attributes: tfsdk.SingleNestedAttributes(
		map[string]tfsdk.Attribute{
			"type": {
				Description:         fmt.Sprintf("The type of the authentication scheme. Possible values are `%s`", client.HTTPAuthTypeBasic),
				MarkdownDescription: fmt.Sprintf("The type of the authentication scheme. Possible values are `%s`", client.HTTPAuthTypeBasic),
				Required:            true,
				Type:                types.StringType,
				Validators:          []tfsdk.AttributeValidator{validator.StringInSlice(string(client.HTTPAuthTypeBasic))},
			},
			"username": {
				Description:         "The username",
				MarkdownDescription: "The username",
				Type:                types.StringType,
				Optional:            true,
			},
			"password": {
				Description:         "The user password",
				MarkdownDescription: "The user password",
				Type:                types.StringType,
				Optional:            true,
				Sensitive:           true,
			},
		},
	),
},

Terraform Configuration Files

    http = {
      type     = "Basic"
      username = "magodo"
      password = "***"
      foo      = "bar" # undefined
    }

Expected Behavior

Running terraform validate, it should error out as there is an undefined attribute foo in the http object.

An argument named "foo" is not expected here.

Actual Behavior

Success! The configuration is valid, but there were some validation warnings as shown above.
@magodo magodo added the bug Something isn't working label Apr 25, 2022
@bflad
Copy link
Contributor

bflad commented Apr 25, 2022

Hi @magodo 👋 Thank you for reporting this. It was discovered that terraform-plugin-sdk/v2 contained some of the validation logic, rather than Terraform CLI itself using the schema data passed across the protocol. To that end, there is hashicorp/terraform#30669 upstream to track this change so any provider implementation receives the benefits, including those written directly in terraform-plugin-go. Please 👍 and subscribe to that issue for further updates on this.

@bflad bflad added the upstream-terraform Issues that relate to Terraform CLI changes label Apr 25, 2022
@bflad
Copy link
Contributor

bflad commented Apr 27, 2022

I forgot we have a similar issue here, #276, as well, so in an effort to consolidate it to one tracking issue on each side, I'm going to close this in preference of #276 which also references hashicorp/terraform#30669. Thanks again for raising this and hopefully it can be addressed shortly.

@bflad bflad closed this as completed Apr 27, 2022
@github-actions
Copy link

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working upstream-terraform Issues that relate to Terraform CLI changes
Projects
None yet
Development

No branches or pull requests

2 participants