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

New Check: Avoid Invalid ConflictsWith Values #104

Closed
bflad opened this issue Mar 18, 2020 · 0 comments · Fixed by #105
Closed

New Check: Avoid Invalid ConflictsWith Values #104

bflad opened this issue Mar 18, 2020 · 0 comments · Fixed by #105
Labels
ast AST Handling check/schema Schema Check new-check New Lint Check
Milestone

Comments

@bflad
Copy link
Owner

bflad commented Mar 18, 2020

Description

Terraform Plugin SDK v1 performs separate validation of the attribute keys given to helper/schema.Schema.ConflictsWith versus the method used to perform the conflict logic during runtime. Differences in the logic leave ambiguity between the flatmap syntax accepted by the schema validation versus what attributes can actually exist during runtime and report the user interface error messaging. While any logic fixes will need to occur in the SDK, the linter can at least report always invalid index syntax for these strings, since ConflictsWith cannot properly work with map syntax (neither for TypeMap attributes (properly fails schema validation) nor TypeList/TypeSet configuration block attributes (never will show conflict)).

Flagged Code

&schema.Schema{
  ConflictsWith: []string{"config_block_attr.nested_attr"},
},

&schema.Schema{
  ConflictsWith: []string{"config_block_attr.0.nested_attr.really_nested_attr"},
},

Passing Code

&schema.Schema{
  ConflictsWith: []string{"config_block_attr.0.nested_attr"},
},

&schema.Schema{
  ConflictsWith: []string{"config_block_attr.0.nested_attr.0.really_nested_attr"},
},

References

Amongst many:

@bflad bflad added ast AST Handling new-check New Lint Check check/schema Schema Check labels Mar 18, 2020
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 18, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 18, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
@bflad bflad added this to the v0.12.0 milestone Mar 19, 2020
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 19, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Apr 24, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
appilon pushed a commit to hashicorp/terraform-plugin-sdk that referenced this issue Apr 28, 2020
…onflictsWith and list index/map key syntax

Reference: #71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
appilon pushed a commit to hashicorp/terraform-plugin-sdk that referenced this issue Apr 28, 2020
…onflictsWith and list index/map key syntax

Reference: #71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
Mikechoi78 added a commit to Mikechoi78/tfproviderlint that referenced this issue May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast AST Handling check/schema Schema Check new-check New Lint Check
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant