Error when saving state in DataSource Read implementation

hi folks!

i am trying to create a Terraform provider using the Terraform Plugin Framework (v1.1.1).

In my implementation, when I test out the provider, I get the following error:

│ Error: Value Conversion Error
│   with data.circleci_webhooks.project_webhooks,
│   on line 14, in data "circleci_webhooks" "project_webhooks":
│   14: data "circleci_webhooks" "project_webhooks" {
│ An unexpected error was encountered trying to convert from struct value. This is always an error in the provider. Please report the following to the provider
│ developer:
│ couldn't find type information for attribute in supplied attr.Type basetypes.ObjectType

I observed the error above occurred on this line of my (public) code:

I understand that this issue is bubbled up from this specific code:

However, as I am totally new to Go, I’m unsure where the issue is.
I suspect it’s to do with my schema definition, but I have no idea where exactly is basetypes.ObjectType type declared.

Since my source code is public, you can see the entire data source implementation here:

Apologies for dumping a huge chunk of test, but I’m unsure what that cryptic error message means (to me at least).

Thanks folks, for giving this a look :bow:

Hi @kelvintaywl :wave:

Sorry you ran into trouble here.

Looking at the CircleCI Client code you’re using, it appears that info will contain the following:

	info := &models.WebhooksInfo{
		Items: []*models.WebhookInfo{
				WebhookPayload: models.WebhookPayload{
					Events:        nil,
					Name:          "",
					Scope:         nil,
					SigningSecret: "",
					URL:           "",
					VerifyTLS:     false,
				CreatedAt:      strfmt.DateTime{},
				ID:             "",
				UpdatedAt:      strfmt.DateTime{},

I believe the error that you’re seeing is because the webhooks section of your schema does not contain an entry for updated_at. So I think you need to add something like the following:

						"updated_at": schema.StringAttribute{
							MarkdownDescription: "The date and time the webhook was updated",
							Computed:            true,

As an aside, if Scope within a WebhookPayload is nil then the code will panic. If Type within WebhookPayloadScope is nil then that will also cause a panic.


A fix to improve the diagnostics was merged in add better reflect error message.

Once this is released, the diagnostic should provide more detail.


│ couldn't find type information for attribute in supplied attr.Type basetypes.ObjectType


│ couldn't find type information for attribute at webhooks[0].updated_at in supplied attr.Type basetypes.ObjectType

1 Like

hi @bendbennett

Thank you so much for your tips here.
I wanted to share that I was able to resolve the issue thanks to your guidance;
I was indeed missing the updated_at schema declaration!

Thank you for the updates re: the updates too :bowing_man: