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

Error "Provider produced invalid object" when import existing commercetools_project_settings into terraform state #538

Open
stanislavhordiyenko opened this issue Nov 15, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@stanislavhordiyenko
Copy link
Contributor

Version information

  • terraform: 1.9.2
  • terraform provider: 1.17.0

Describe the bug

I would like to create commercetools_project_settings resource and map it (with import { }) to already created project in Commercetools. When I run plan, I get the error below:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Provider produced invalid object
│ 
│ Provider "registry.terraform.io/labd/commercetools" planned an invalid value for commercetools_project_settings.default during refresh: The returned
│ state contains unknown values.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Unfortunately, no information is provided when I ran plan command with debug option, no enough information what went wrong.

2024-11-15T11:35:52.238+1100 [INFO]  Terraform version: 1.9.2
2024-11-15T11:35:52.238+1100 [DEBUG] using github.com/hashicorp/go-tfe v1.51.0
2024-11-15T11:35:52.238+1100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.20.0
2024-11-15T11:35:52.238+1100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-11-15T11:35:52.238+1100 [DEBUG] using github.com/zclconf/go-cty v1.14.4
2024-11-15T11:35:52.238+1100 [INFO]  Go runtime version: go1.22.4
2024-11-15T11:35:52.238+1100 [INFO]  CLI args: []string{"terraform", "plan"}
2024-11-15T11:35:52.238+1100 [DEBUG] Attempting to open CLI config file: /Users/work/.terraformrc
2024-11-15T11:35:52.238+1100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-11-15T11:35:52.239+1100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-11-15T11:35:52.239+1100 [DEBUG] ignoring non-existing provider search directory /Users/work/.terraform.d/plugins
2024-11-15T11:35:52.239+1100 [DEBUG] ignoring non-existing provider search directory /Users/work/Library/Application Support/io.terraform/plugins
2024-11-15T11:35:52.239+1100 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2024-11-15T11:35:52.239+1100 [INFO]  CLI command args: []string{"plan"}
2024-11-15T11:35:52.258+1100 [DEBUG] checking for provisioner in "."
2024-11-15T11:35:52.260+1100 [DEBUG] checking for provisioner in "/opt/homebrew/bin"
2024-11-15T11:35:52.260+1100 [INFO]  backend/local: starting Plan operation
2024-11-15T11:35:52.264+1100 [DEBUG] created provider logger: level=debug
2024-11-15T11:35:52.264+1100 [INFO]  provider: configuring client automatic mTLS
2024-11-15T11:35:52.270+1100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 args=[".terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0"]
2024-11-15T11:35:52.272+1100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 pid=70221
2024-11-15T11:35:52.272+1100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0
2024-11-15T11:35:52.278+1100 [INFO]  provider.terraform-provider-commercetools_v1.17.0: configuring server automatic mTLS: timestamp="2024-11-15T11:35:52.278+1100"
2024-11-15T11:35:52.283+1100 [DEBUG] provider: using plugin: version=5
2024-11-15T11:35:52.283+1100 [DEBUG] provider.terraform-provider-commercetools_v1.17.0: plugin address: address=/var/folders/ws/j88jlndn1kjfvpcd0fd_6ccw0000gn/T/plugin1850456622 network=unix timestamp="2024-11-15T11:35:52.283+1100"
2024-11-15T11:35:52.291+1100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-11-15T11:35:52.291+1100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 id=70221
2024-11-15T11:35:52.291+1100 [DEBUG] provider: plugin exited
2024-11-15T11:35:52.291+1100 [DEBUG] Building and walking validate graph
2024-11-15T11:35:52.291+1100 [DEBUG] ProviderTransformer: "commercetools_project_settings.default" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/labd/commercetools"]
2024-11-15T11:35:52.291+1100 [DEBUG] ReferenceTransformer: "commercetools_project_settings.default" references: []
2024-11-15T11:35:52.291+1100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/labd/commercetools\"]" references: []
2024-11-15T11:35:52.291+1100 [DEBUG] Starting graph walk: walkValidate
2024-11-15T11:35:52.292+1100 [DEBUG] created provider logger: level=debug
2024-11-15T11:35:52.292+1100 [INFO]  provider: configuring client automatic mTLS
2024-11-15T11:35:52.294+1100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 args=[".terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0"]
2024-11-15T11:35:52.295+1100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 pid=70222
2024-11-15T11:35:52.295+1100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0
2024-11-15T11:35:52.302+1100 [INFO]  provider.terraform-provider-commercetools_v1.17.0: configuring server automatic mTLS: timestamp="2024-11-15T11:35:52.302+1100"
2024-11-15T11:35:52.306+1100 [DEBUG] provider: using plugin: version=5
2024-11-15T11:35:52.306+1100 [DEBUG] provider.terraform-provider-commercetools_v1.17.0: plugin address: network=unix address=/var/folders/ws/j88jlndn1kjfvpcd0fd_6ccw0000gn/T/plugin1344303626 timestamp="2024-11-15T11:35:52.306+1100"
2024-11-15T11:35:52.313+1100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-11-15T11:35:52.313+1100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 id=70222
2024-11-15T11:35:52.313+1100 [DEBUG] provider: plugin exited
2024-11-15T11:35:52.313+1100 [INFO]  backend/local: plan calling Plan
2024-11-15T11:35:52.313+1100 [DEBUG] Building and walking plan graph for NormalMode
2024-11-15T11:35:52.313+1100 [DEBUG] ProviderTransformer: "commercetools_project_settings.default (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/labd/commercetools"]
2024-11-15T11:35:52.313+1100 [DEBUG] ReferenceTransformer: "commercetools_project_settings.default (expand)" references: []
2024-11-15T11:35:52.313+1100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/labd/commercetools\"]" references: []
2024-11-15T11:35:52.314+1100 [DEBUG] Starting graph walk: walkPlan
2024-11-15T11:35:52.314+1100 [DEBUG] created provider logger: level=debug
2024-11-15T11:35:52.314+1100 [INFO]  provider: configuring client automatic mTLS
2024-11-15T11:35:52.315+1100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 args=[".terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0"]
2024-11-15T11:35:52.317+1100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0 pid=70223
2024-11-15T11:35:52.317+1100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/labd/commercetools/1.17.0/darwin_arm64/terraform-provider-commercetools_v1.17.0
2024-11-15T11:35:52.323+1100 [INFO]  provider.terraform-provider-commercetools_v1.17.0: configuring server automatic mTLS: timestamp="2024-11-15T11:35:52.323+1100"
2024-11-15T11:35:52.327+1100 [DEBUG] provider: using plugin: version=5
2024-11-15T11:35:52.327+1100 [DEBUG] provider.terraform-provider-commercetools_v1.17.0: plugin address: address=/var/folders/ws/j88jlndn1kjfvpcd0fd_6ccw0000gn/T/plugin3845565809 network=unix timestamp="2024-11-15T11:35:52.327+1100"
2024-11-15T11:35:52.332+1100 [DEBUG] Resource instance state not found for node "commercetools_project_settings.default", instance commercetools_project_settings.default
2024-11-15T11:35:52.332+1100 [DEBUG] ReferenceTransformer: "commercetools_project_settings.default" references: []
commercetools_project_settings.default: Preparing import... [id=xxx-prod]
commercetools_project_settings.default: Refreshing state... [id=xxx-prod]
2024-11-15T11:35:52.474+1100 [DEBUG] provider.terraform-provider-commercetools_v1.17.0: Value switched to prior value due to semantic equality logic: tf_rpc=ReadResource @module=sdk.framework tf_mux_provider="*proto5server.Server" tf_provider_addr=registry.terraform.io/labd/commercetools tf_req_id=a172a6c9-d13c-a232-e3a6-67dc81af1af3 tf_resource_type=commercetools_project_settings @caller=github.com/hashicorp/[email protected]/internal/fwschemadata/value_semantic_equality.go:91 tf_attribute_path=id timestamp="2024-11-15T11:35:52.473+1100"
2024-11-15T11:35:52.475+1100 [ERROR] vertex "commercetools_project_settings.default" error: Provider produced invalid object
2024-11-15T11:35:52.475+1100 [ERROR] vertex "commercetools_project_settings.default (expand)" error: Provider produced invalid object
2024-11-15T11:35:52.475+1100 [WARN]  Planning encountered errors, so plan is not applyable
2024-11-15T11:35:52.475+1100 [INFO]  backend/local: plan operation completed

Planning failed. Terraform encountered an error while generating this plan.

I added all scopes for API key.

I usually add a bare minimum to the resource, and then add import block so that terraform can show me exactly what is missing or needs to be changed, so that I can reflect this in code.

Could you please suggest me what information to provide so that we can identify and fix the issue?

On contrary, when I run this on an empty project with no configuration, it works. Even with limited scopes for the API key.

Thank you.

@stanislavhordiyenko stanislavhordiyenko added bug Something isn't working triage Needs triage labels Nov 15, 2024
@stanislavhordiyenko
Copy link
Contributor Author

Looks like it is something to do with totalPriceDiscountDoesNotReduceExternalTax field of the Cart that was recently introduced. The resource works fine for the newly created projects, but for the old one this field is set to false by default. Resource commercetools_project_settings works perfectly fine util I asked support to sync this particular field with the other existing project where it is set to false and terraform doesn't work after this change. Same error as above.

@demeyerthom
Copy link
Member

Hi @stanislavhordiyenko Thanks for the additional info. I will take a look!

@demeyerthom demeyerthom removed the triage Needs triage label Nov 22, 2024
@demeyerthom demeyerthom self-assigned this Nov 22, 2024
@stanislavhordiyenko
Copy link
Contributor Author

@demeyerthom please let me know if you need more information on this issue. I am more than happy to provide you with more details.

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