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

tfsdk: Prevent configuration handling error when Schema contains Blocks #371

Merged
merged 3 commits into from
Jun 13, 2022

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jun 9, 2022

Closes #328

Previously the framework could return errors similar to the following:

Error: Error parsing config

The provider had a problem parsing the config. Report this to the provider
developer:
AttributeName("example").ElementKeyInt(0): error decoding object; expected 0
attributes, got 5

New unit testing failures before fix:

--- FAIL: TestBlockAttributeType (0.00s)
    --- FAIL: TestBlockAttributeType/NestingMode-Set (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:103: unexpected difference:   types.SetType(
            - 	s`types.SetType[types.ObjectType["test_attribute":types.StringType]]`,
            + 	s`types.SetType[types.ObjectType["test_attribute":types.StringType, "test_block":types.SetType[types.ObjectType["test_block_attribute":types.StringType]]]]`,
              )
    --- FAIL: TestBlockAttributeType/NestingMode-List (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:103: unexpected difference:   types.ListType(
            - 	s`types.ListType[types.ObjectType["test_attribute":types.StringType]]`,
            + 	s`types.ListType[types.ObjectType["test_attribute":types.StringType, "test_block":types.ListType[types.ObjectType["test_block_attribute":types.StringType]]]]`,
              )

--- FAIL: TestBlockTerraformType (0.00s)
    --- FAIL: TestBlockTerraformType/NestingMode-List (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:199: unexpected difference:   tftypes.List(
            - 	s`tftypes.List[tftypes.Object["test_attribute":tftypes.String]]`,
            + 	s`tftypes.List[tftypes.Object["test_attribute":tftypes.String, "test_block":tftypes.List[tftypes.Object["test_block_attribute":tftypes.String]]]]`,
              )
    --- FAIL: TestBlockTerraformType/NestingMode-Set (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:199: unexpected difference:   tftypes.Set(
            - 	s`tftypes.Set[tftypes.Object["test_attribute":tftypes.String]]`,
            + 	s`tftypes.Set[tftypes.Object["test_attribute":tftypes.String, "test_block":tftypes.Set[tftypes.Object["test_block_attribute":tftypes.String]]]]`,
              )

Reference: #328

Previously the framework could return errors similar to the following:

```
Error: Error parsing config

The provider had a problem parsing the config. Report this to the provider
developer:
AttributeName("output").ElementKeyInt(0): error decoding object; expected 0
attributes, got 5
```

New unit testing failures before fix:

```
--- FAIL: TestBlockAttributeType (0.00s)
    --- FAIL: TestBlockAttributeType/NestingMode-Set (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:103: unexpected difference:   types.SetType(
            - 	s`types.SetType[types.ObjectType["test_attribute":types.StringType]]`,
            + 	s`types.SetType[types.ObjectType["test_attribute":types.StringType, "test_block":types.SetType[types.ObjectType["test_block_attribute":types.StringType]]]]`,
              )
    --- FAIL: TestBlockAttributeType/NestingMode-List (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:103: unexpected difference:   types.ListType(
            - 	s`types.ListType[types.ObjectType["test_attribute":types.StringType]]`,
            + 	s`types.ListType[types.ObjectType["test_attribute":types.StringType, "test_block":types.ListType[types.ObjectType["test_block_attribute":types.StringType]]]]`,
              )

--- FAIL: TestBlockTerraformType (0.00s)
    --- FAIL: TestBlockTerraformType/NestingMode-List (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:199: unexpected difference:   tftypes.List(
            - 	s`tftypes.List[tftypes.Object["test_attribute":tftypes.String]]`,
            + 	s`tftypes.List[tftypes.Object["test_attribute":tftypes.String, "test_block":tftypes.List[tftypes.Object["test_block_attribute":tftypes.String]]]]`,
              )
    --- FAIL: TestBlockTerraformType/NestingMode-Set (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/tfsdk/block_test.go:199: unexpected difference:   tftypes.Set(
            - 	s`tftypes.Set[tftypes.Object["test_attribute":tftypes.String]]`,
            + 	s`tftypes.Set[tftypes.Object["test_attribute":tftypes.String, "test_block":tftypes.Set[tftypes.Object["test_block_attribute":tftypes.String]]]]`,
              )
```
@bflad bflad added the bug Something isn't working label Jun 9, 2022
@bflad bflad added this to the v0.9.0 milestone Jun 9, 2022
@bflad bflad requested a review from a team as a code owner June 9, 2022 23:49
@bflad bflad changed the title tfsdk: Prevent configuration handling error when Schema contained Blocks tfsdk: Prevent configuration handling error when Schema contains Blocks Jun 9, 2022
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@detro detro left a comment

Choose a reason for hiding this comment

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

LGTM

@bflad bflad merged commit dfb09a6 into main Jun 13, 2022
@bflad bflad deleted the bflad-tfsdk-block-terraformtype branch June 13, 2022 17:37
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, 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 Jul 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error decoding attributes/blocks
3 participants