Json: cannot unmarshal array into Go struct field response.versions of type utils.versionsResp

Hi all,

Having an issue creating a VM in Openstack compute, when I try and create it throws the error message in the title. After having a look on github there is one other instance of this where the resolution is to change variable name “image and flavor” name to ID which resolves the issue but in my instance it doesnt.

As you can see from below the main.tf file is very bare bones and switching between image and flavour name and ID does not work so wondering if anyone has any advice or help. Please see details below.

Terraform Version

Terraform v1.5.1 on linux_amd64 + provider Terraform Registry v1.51.1

Terraform Configuration Files

terraform {
required_version = “>= 0.14.0”
required_providers {
openstack = {
source = “terraform-provider-openstack/openstack”
version = “~> 1.51.1”
}
}
}

Configure the OpenStack Provider

provider “openstack” {
user_name = “user”
password = “var.password”
auth_url = “https://XXXX.domain:port/version”
tenant_name = “IOG-LinuxsandBox”
}

resource “openstack_compute_instance_v2” “terraformTest” {
name = “terraformTest”
image_id = “e47442c9-3ec9-427f-90d7-6327f84c19c4”
flavor_id = “ic.small”
key_pair = “key”
security_groups = [“default”]

network {
name = “Private”
}
}

variable “password” {
description = “Password for signin”
type = string
sensitive = true
}

Error: Error creating OpenStack compute client: json: cannot unmarshal array into Go struct field response.versions of type utils.versionsResp

│ with openstack_compute_instance_v2.terraformTest,
│ on main.tf line 19, in resource “openstack_compute_instance_v2” “terraformTest”:
│ 19: resource “openstack_compute_instance_v2” “terraformTest” {

Link to previous issue:

Welcome to the forum - please reformat your message

The error you report, means that the client library for interacting with the OpenStack API is failing to process the shape of the JSON returned from the OpenStack server. This probably indicates a bug in the client code.

You should attempt the apply with TF_LOG_PROVIDER=debug in the environment and see if the extra debug logging enables you to identify the exact OpenStack API call that is failing, and what is being returned. You can swap debug for trace to turn the logging level up even higher, if needed.

Hi Max,

I have run the debug before but personally havent found there to be much other than was the error message it is saying unless im missing something:

2023-06-26T10:53:49.641+0100 [INFO] provider.terraform-provider-openstack_v1.51.1: 2023/06/26 10:53:49 [DEBUG] Unlocking “auth”: timestamp=2023-06-26T10:53:49.641+0100
2023-06-26T10:53:49.642+0100 [INFO] provider.terraform-provider-openstack_v1.51.1: 2023/06/26 10:53:49 [DEBUG] Unlocked “auth”: timestamp=2023-06-26T10:53:49.641+0100
2023-06-26T10:53:49.642+0100 [TRACE] provider.terraform-provider-openstack_v1.51.1: Called downstream: tf_provider_addr=Terraform Registry @module=sdk.helper_schema tf_req_id=833bae44-cdd8-7ca2-d19e-079269ab1c56 tf_resource_type=openstack_compute_instance_v2 tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:838 timestamp=2023-06-26T10:53:49.641+0100
2023-06-26T10:53:49.642+0100 [TRACE] provider.terraform-provider-openstack_v1.51.1: Received downstream response: @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tf5serverlogging/downstream_request.go:37 diagnostic_warning_count=0 tf_rpc=ApplyResourceChange tf_req_id=833bae44-cdd8-7ca2-d19e-079269ab1c56 tf_resource_type=openstack_compute_instance_v2 @module=sdk.proto diagnostic_error_count=1 tf_proto_version=5.3 tf_provider_addr=Terraform Registry tf_req_duration_ms=419 timestamp=2023-06-26T10:53:49.642+0100
2023-06-26T10:53:49.642+0100 [ERROR] provider.terraform-provider-openstack_v1.51.1: Response contains error diagnostic: diagnostic_detail= tf_rpc=ApplyResourceChange tf_proto_version=5.3 @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto diagnostic_severity=ERROR diagnostic_summary=“Error creating OpenStack compute client: json: cannot unmarshal array into Go struct field response.versions of type utils.versionsResp” tf_provider_addr=Terraform Registry tf_req_id=833bae44-cdd8-7ca2-d19e-079269ab1c56 tf_resource_type=openstack_compute_instance_v2 timestamp=2023-06-26T10:53:49.642+0100
2023-06-26T10:53:49.642+0100 [TRACE] provider.terraform-provider-openstack_v1.51.1: Served request: tf_req_id=833bae44-cdd8-7ca2-d19e-079269ab1c56 @module=sdk.proto tf_proto_version=5.3 tf_provider_addr=Terraform Registry tf_resource_type=openstack_compute_instance_v2 tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:831 timestamp=2023-06-26T10:53:49.642+0100
2023-06-26T10:53:49.642+0100 [TRACE] maybeTainted: openstack_compute_instance_v2.terraformTest encountered an error during creation, so it is now marked as tainted
2023-06-26T10:53:49.642+0100 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for openstack_compute_instance_v2.terraformTest
2023-06-26T10:53:49.642+0100 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for openstack_compute_instance_v2.terraformTest
2023-06-26T10:53:49.642+0100 [TRACE] evalApplyProvisioners: openstack_compute_instance_v2.terraformTest is tainted, so skipping provisioning
2023-06-26T10:53:49.642+0100 [TRACE] maybeTainted: openstack_compute_instance_v2.terraformTest was already tainted, so nothing to do
2023-06-26T10:53:49.642+0100 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for openstack_compute_instance_v2.terraformTest
2023-06-26T10:53:49.642+0100 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for openstack_compute_instance_v2.terraformTest
2023-06-26T10:53:49.643+0100 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2023-06-26T10:53:49.643+0100 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2023-06-26T10:53:49.643+0100 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2023-06-26T10:53:49.644+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-06-26T10:53:49.644+0100 [ERROR] vertex “openstack_compute_instance_v2.terraformTest” error: Error creating OpenStack compute client: json: cannot unmarshal array into Go struct field response.versions of type utils.versionsResp
2023-06-26T10:53:49.644+0100 [TRACE] vertex “openstack_compute_instance_v2.terraformTest”: visit complete, with errors
2023-06-26T10:53:49.644+0100 [TRACE] dag/walk: upstream of “provider["registry.terraform.io/terraform-provider-openstack/openstack"] (close)” errored, so skipping
2023-06-26T10:53:49.644+0100 [TRACE] dag/walk: upstream of “root” errored, so skipping
2023-06-26T10:53:49.644+0100 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2023-06-26T10:53:49.644+0100 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2023-06-26T10:53:49.644+0100 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate

│ Error: Error creating OpenStack compute client: json: cannot unmarshal array into Go struct field response.versions of type utils.versionsResp

│ with openstack_compute_instance_v2.terraformTest,
│ on main.tf line 19, in resource “openstack_compute_instance_v2” “terraformTest”:
│ 19: resource “openstack_compute_instance_v2” “terraformTest” {

It is possible that terraform-provider-openstack just doesn’t log much. It would be necessary to examine the source code to make sure.

It’s probably worth filing a GitHub issue at this point, unless you find an existing very similar one. It certainly seems like there’s a bug of some sort.

Any information you can provide to help someone else reproduce the problem would be helpful. I don’t have my own OpenStack instance, though, so I can’t try.

Hi,

I did raise this in the Terraform Github but they advised I came here :frowning:

Kind regards,
Shane

Link?

Also note that the Terraform project can do nothing about this, this is firmly within the scope of terraform-provider-openstack.