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: internal validation failed; object ID is not set, but may have been created; this should never happen #257

Open
japerrin opened this issue Jan 10, 2024 · 1 comment

Comments

@japerrin
Copy link

Hi

I tried to create a VMware NSX-V "logical switch" object with:
resource "restapi_object" "create_logical_switch" {
path = "/api/2.0/vdn/scopes/${local.transport_zone_id}/virtualwires"
read_path = "/api/2.0/vdn/virtualwires"
data = local.body_json
object_id = "*"
}

locals {

Build body

body = {
name = var.logical_switch_name,
description = var.logical_switch_description,
tenantId = local.tenant_id,
guestVlanAllowed = false
}

body_json = jsonencode(local.body)
}

The URI is different to create object and get its properties, so I set the path and read_path.

I have an issue when I create the object, the NSX-V API return the id BUT the ID is returned as raw like:
"virtualwire-12"

and not formated like:
{"id": "virtualwire-12"}

So I have the error message:
Error: internal validation failed; object ID is not set, but may have been created; this should never happen

The object is created but terraform return an error

How can I do to reformat the response raw from "virtualwire-12" to {"id": "virtualwire-12"} ?

Thanks a lot
Jacques

S3B4SZ17 pushed a commit to S3B4SZ17/terraform-provider-restapi that referenced this issue Mar 10, 2024
… we can identify we are not getting a formatted JSON response object

If we get a response as a string or int we are assigning that response
as the id of the obj. We need to set the `id_attribute` to `*`
S3B4SZ17 pushed a commit to S3B4SZ17/terraform-provider-restapi that referenced this issue Mar 10, 2024
* Adding a Makefile for simplicity to build the project and clean it, also
to run the tests more easily
* Updated the fakeserver so we can test the new func for non JSON
  responses
S3B4SZ17 pushed a commit to S3B4SZ17/terraform-provider-restapi that referenced this issue Mar 10, 2024
@S3B4SZ17
Copy link

Hi @japerrin I created the above PR adding that functionality. Please feel free to review it and share any thoughts.

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

No branches or pull requests

2 participants