Skip to content

fix: equinix_metal_organization.project_ids data#781

Draft
billf wants to merge 2 commits intoequinix:mainfrom
billf:main
Draft

fix: equinix_metal_organization.project_ids data#781
billf wants to merge 2 commits intoequinix:mainfrom
billf:main

Conversation

@billf
Copy link

@billf billf commented Sep 20, 2024

No description provided.

@billf billf changed the title Fix equinix_metal_organization.project_ids data [fix] equinix_metal_organization.project_ids data Sep 20, 2024
@billf billf changed the title [fix] equinix_metal_organization.project_ids data fix: equinix_metal_organization.project_ids data Sep 20, 2024
@displague
Copy link
Member

Thanks for opening this PR, @billf.

The changes make sense. What error did you receive that triggered this PR?

@billf
Copy link
Author

billf commented Sep 24, 2024

data "equinix_metal_project" "production" {
  name = "whatever"
}

// This panics.
data "equinix_metal_organization" "org" {
  organization_id = data.equinix_metal_project.production.organization_id
}
│   with data.equinix_metal_organization.org,
│   on main.tf line 19, in data "equinix_metal_organization" "org":
│   19: data "equinix_metal_organization" "org" {
│
│ An unexpected error was encountered while verifying an attribute value matched its expected type to prevent unexpected behavior or panics. This is always an error in the provider. Please
│ report the following to the provider developer:
│
│ Expected framework type from provider logic: basetypes.StringType / underlying type: tftypes.String
│ Received framework type from provider logic: types.ListType[!!! MISSING TYPE !!!] / underlying type: tftypes.List[tftypes.DynamicPseudoType]
│ Path: project_ids[0]
╵

@ctreatma
Copy link
Contributor

ctreatma commented Sep 25, 2024

@billf would you be able to add a test covering this behavior so we can avoid reintroducing the bug in the future?

The test would look a lot like the existing organization data source test: https://github.com/equinix/terraform-provider-equinix/blob/e158a616ca5ed96ff0aed1ce18f9a396637c1973/internal/resources/metal/organization/datasource_test.go,
but modified to ensure that a project is created for the test organization before the data source runs:

resource "equinix_metal_organization" "test" {
	name = "tfacc-datasource-org-%d"
	description = "quux"
	address {
		address = "tfacc org street"
		city = "london"
		zip_code = "12345"
		country = "GB"
	}
}

resource "equinix_metal_project" "test" {
  name = "tfacc-datasource-org-project"
  organization_id = equinix_metal_organization.test.id
}

data "equinix_metal_organization" "test" {
  organization_id = equinix_metal_project.test.id
}

@billf
Copy link
Author

billf commented Sep 26, 2024

@billf would you be able to add a test covering this behavior so we can avoid reintroducing the bug in the future?

@ctreatma not a problem; it's actually why this PR has remained in draft mode.

The test would look a lot like the existing organization data source test: https://github.com/equinix/terraform-provider-equinix/blob/e158a616ca5ed96ff0aed1ce18f9a396637c1973/internal/resources/metal/organization/datasource_test.go, but modified to ensure that a project is created for the test organization before the data source runs:

i'll take a look, thanks for the pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants