-
Notifications
You must be signed in to change notification settings - Fork 95
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
Error decoding attributes/blocks #328
Comments
Hi @abergmeier 👋 Thank you for reporting this and sorry you ran into trouble here. I was able to successfully reproduce the issue. Good news is that some of our recent refactoring efforts have improved the error messaging here already. On
Bad news is that there certainly is unexpected behavior here in the framework that needs to be fixed to prevent the issue as I'm not immediately seeing anything wrong with that schema definition. I'm running out of time during my work day today and I'm offline tomorrow, but will keep you posted next week. |
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]]]]`, ) ```
Turns out I was able to find the issue and submit #371 right now, which prevents the error and introduces extra unit testing to cover similar functionality. I was also able to verify the fix in the reproduction provider that previously threw the error. |
…ks (#371) 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]]]]`, ) ```
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. |
Module version
Relevant provider source code
Terraform Configuration Files
Expected Behavior
It should map config to Schema or indicate what is actually the problem.
Actual Behavior
It reported an error about Attributes while there seem to be only Blocks used:
Steps to Reproduce
CGO_ENABLED=0 TF_ACC=1 TF_LOG=trace go test ./internal/resources/builttest -v
References
The text was updated successfully, but these errors were encountered: