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

Unexpected error NestingSet blocks may not contain attributes of cty.DynamicPseudoType #343

Closed
1 task done
ewbankkit opened this issue Mar 7, 2024 · 3 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@ewbankkit
Copy link
Contributor

ewbankkit commented Mar 7, 2024

Terraform CLI and terraform-plugin-docs Versions

% tfplugindocs -v
tfplugindocs Version dev

Provider Code

"framework_controls": schema.SetNestedAttribute{ /*START ATTRIBUTE*/
			NestedObject: schema.NestedAttributeObject{ /*START NESTED OBJECT*/
				Attributes: map[string]schema.Attribute{ /*START SCHEMA*/
					// Property: ControlInputParameters
					"control_input_parameters": schema.SetNestedAttribute{ /*START ATTRIBUTE*/
						NestedObject: schema.NestedAttributeObject{ /*START NESTED OBJECT*/
							Attributes: map[string]schema.Attribute{ /*START SCHEMA*/
								// Property: ParameterName
								"parameter_name": schema.StringAttribute{ /*START ATTRIBUTE*/
									Required: true,
								}, /*END ATTRIBUTE*/
								// Property: ParameterValue
								"parameter_value": schema.StringAttribute{ /*START ATTRIBUTE*/
									Required: true,
								}, /*END ATTRIBUTE*/
							}, /*END SCHEMA*/
						}, /*END NESTED OBJECT*/
						Description: "A list of ParameterName and ParameterValue pairs.",
						Optional:    true,
						Computed:    true,
						PlanModifiers: []planmodifier.Set{ /*START PLAN MODIFIERS*/
							setplanmodifier.UseStateForUnknown(),
						}, /*END PLAN MODIFIERS*/
					}, /*END ATTRIBUTE*/
					// Property: ControlName
					"control_name": schema.StringAttribute{ /*START ATTRIBUTE*/
						Description: "The name of a control. This name is between 1 and 256 characters.",
						Required:    true,
					}, /*END ATTRIBUTE*/
					// Property: ControlScope
					"control_scope": schema.SingleNestedAttribute{ /*START ATTRIBUTE*/
						Attributes: map[string]schema.Attribute{ /*START SCHEMA*/
							// Property: ComplianceResourceIds
							"compliance_resource_ids": schema.ListAttribute{ /*START ATTRIBUTE*/
								ElementType: types.StringType,
								CustomType:  cctypes.MultisetType,
								Description: "The ID of the only AWS resource that you want your control scope to contain.",
								Optional:    true,
								Computed:    true,
								PlanModifiers: []planmodifier.List{ /*START PLAN MODIFIERS*/
									listplanmodifier.UseStateForUnknown(),
								}, /*END PLAN MODIFIERS*/
							}, /*END ATTRIBUTE*/
							// Property: ComplianceResourceTypes
							"compliance_resource_types": schema.ListAttribute{ /*START ATTRIBUTE*/
								ElementType: types.StringType,
								CustomType:  cctypes.MultisetType,
								Description: "Describes whether the control scope includes one or more types of resources, such as `EFS` or `RDS`.",
								Optional:    true,
								Computed:    true,
								PlanModifiers: []planmodifier.List{ /*START PLAN MODIFIERS*/
									listplanmodifier.UseStateForUnknown(),
								}, /*END PLAN MODIFIERS*/
							}, /*END ATTRIBUTE*/
							// Property: Tags
							"tags": schema.ListNestedAttribute{ /*START ATTRIBUTE*/
								NestedObject: schema.NestedAttributeObject{ /*START NESTED OBJECT*/
									Attributes: map[string]schema.Attribute{ /*START SCHEMA*/
										// Property: Key
										"key": schema.StringAttribute{ /*START ATTRIBUTE*/
											Description: "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.",
											Optional:    true,
											Computed:    true,
											Validators: []validator.String{ /*START VALIDATORS*/
												stringvalidator.LengthBetween(1, 128),
											}, /*END VALIDATORS*/
											PlanModifiers: []planmodifier.String{ /*START PLAN MODIFIERS*/
												stringplanmodifier.UseStateForUnknown(),
											}, /*END PLAN MODIFIERS*/
										}, /*END ATTRIBUTE*/
										// Property: Value
										"value": schema.StringAttribute{ /*START ATTRIBUTE*/
											Description: "The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.",
											Optional:    true,
											Computed:    true,
											Validators: []validator.String{ /*START VALIDATORS*/
												stringvalidator.LengthBetween(0, 256),
											}, /*END VALIDATORS*/
											PlanModifiers: []planmodifier.String{ /*START PLAN MODIFIERS*/
												stringplanmodifier.UseStateForUnknown(),
											}, /*END PLAN MODIFIERS*/
										}, /*END ATTRIBUTE*/
									}, /*END SCHEMA*/
								}, /*END NESTED OBJECT*/
								CustomType:  cctypes.MultisetType,
								Description: "Describes whether the control scope includes resources with one or more tags. Each tag is a key-value pair.",
								Optional:    true,
								Computed:    true,
								PlanModifiers: []planmodifier.List{ /*START PLAN MODIFIERS*/
									listplanmodifier.UseStateForUnknown(),
								}, /*END PLAN MODIFIERS*/
							}, /*END ATTRIBUTE*/
						}, /*END SCHEMA*/
						Description: "The scope of a control. The control scope defines what the control will evaluate. Three examples of control scopes are: a specific backup plan, all backup plans with a specific tag, or all backup plans.",
						Optional:    true,
						Computed:    true,
						PlanModifiers: []planmodifier.Object{ /*START PLAN MODIFIERS*/
							objectplanmodifier.UseStateForUnknown(),
						}, /*END PLAN MODIFIERS*/
					}, /*END ATTRIBUTE*/
				}, /*END SCHEMA*/
			}, /*END NESTED OBJECT*/
			Description: "Contains detailed information about all of the controls of a framework. Each framework must contain at least one control.",
			Required:    true,
		}, /*END ATTRIBUTE*/

Expected Behavior

Generation OK

Actual Behavior

Error while loading schemas for plugin components: Failed to obtain provider
schema: Could not load the schema for provider
registry.terraform.io/hashicorp/awscc: provider
registry.terraform.io/hashicorp/awscc has invalid schema for managed resource
type "awscc_backup_framework", which is a bug in the provider: "1 error
occurred:\n\t* framework_controls: NestingSet blocks may not contain
attributes of cty.DynamicPseudoType\n\n"..

Steps to Reproduce

  1. tfplugindocs generate --flags

How much impact is this issue causing?

Medium

Logs

See https://github.com/hashicorp/terraform-provider-awscc/actions/runs/8188993378/job/22392712731.

Additional Information

Relates hashicorp/terraform-provider-awscc#1463.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ewbankkit ewbankkit added the bug Something isn't working label Mar 7, 2024
@bendbennett
Copy link
Contributor

Hey @ewbankkit 👋

Sorry you ran into trouble here. I can reproduce the issue you describe, and it looks to me as though the issue arises as a consequence of the schema definition. Specifically, in the case of ListAttribute, the example you provided has entries such as:

	ElementType: types.StringType,
	CustomType:  cctypes.MultisetType,

I believe that these will need to be replaced by something along the following lines:

	CustomType:  multisetType{basetypes.ListType{ElemType: types.StringType}},

@ewbankkit
Copy link
Contributor Author

@bendbennett Thanks for responding.
Yes, this is tied to the resolution that @bflad suggests for #342.
I'll close this Issue once that solution is verified.

@ewbankkit
Copy link
Contributor Author

Yes, removing ElementType works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants