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

Open
npfp opened this issue Nov 8, 2024 · 0 comments

Comments

@npfp
Copy link

npfp commented Nov 8, 2024

What I want to achieve

Make a REST call to turn on a config flag on an object right after its creation as a ressource in terraform.

Config used and tested

provider "restapi" {
  uri                  = module.cluster.schema_registry.rest_endpoint
  write_returns_object = true # or false that doesn't make any difference
  create_returns_object = true # or false that doesn't make any difference
  debug                = true

  headers = {
    "Content-Type" = "application/vnd.schemaregistry.v1+json"
  }

  username = module.cluster.schema_registry_api_key
  password = module.cluster.schema_registry_api_secret

  create_method  = "PUT"
  destroy_method = "PUT"
  update_method  = "PUT"
  read_method    = "GET"
}

resource "restapi_object" "this" {
  path         = "/config"
  read_path    = "/config"
  update_path  = "/config"
  destroy_path = "/config"

  id_attribute    = "normalize"
  read_data      = ""
  data                = jsonencode({ "normalize" : true })
  update_data  = jsonencode({ "normalize" : true })

  debug = true
}

Logs

2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 resource_api_object.go: Create routine called. Object built:
id: 
get_path: /config
post_path: /config
put_path: /config
delete_path: /config
query_string: 
create_method: PUT
read_method: GET
update_method: PUT
destroy_method: PUT
debug: true
read_search: (map[string]string) {
}

data: (map[string]interface {}) (len=1) {
 (string) (len=9) "normalize": (bool) true
}

read_data: (map[string]interface {}) {
}

update_data: (map[string]interface {}) (len=1) {
 (string) (len=9) "normalize": (bool) true
}

destroy_data: (map[string]interface {}) {
}

api_data: (map[string]interface {}) {
}: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: method='PUT', path='/config', full uri (derived)='https://psrc-lq3wm.eu-central-1.aws.confluent.cloud/config', data='{"normalize":true}': timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: Sending HTTP request to https://psrc-lq3wm.eu-central-1.aws.confluent.cloud/config...: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: Request headers:: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go:   Authorization: Basic **************: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go:   Content-Type: application/vnd.schemaregistry.v1+json: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: BODY:: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.064Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 {"normalize":true}: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.065Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 Waiting for rate limit availability: timestamp=2024-11-08T08:27:32.064Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: Response code: 200: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: Response headers:: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go:   Content-Length: 18: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go:   Date: Fri, 08 Nov 2024 08:27:32 GMT: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go:   X-Request-Id: b93cf958-fe19-4cc6-9aed-63c036703239: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go:   Content-Type: application/vnd.schemaregistry.v1+json: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: BODY:
{"normalize":true}: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_object.go: Parsing response from POST to update internal structures (write_returns_object=true, create_returns_object=true)...: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_object.go: Updating API object state to '{"normalize":true}': timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 common.go:GetObjectAtKey: Locating results_key in parts: [normalize]...: timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.582Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 common.go:GetObjectAtKey:  normalize - exists (true): timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.582Z [TRACE] provider.terraform-provider-restapi_v1.20.0: Called downstream: @module=sdk.helper_schema tf_provider_addr=provider tf_req_id=1ebc0be8-c74d-04ba-bf5f-dc804764ff1d tf_resource_type=restapi_object tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:865 timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.582Z [TRACE] provider.terraform-provider-restapi_v1.20.0: Received downstream response: @module=sdk.proto tf_provider_addr=provider tf_resource_type=restapi_object tf_rpc=ApplyResourceChange diagnostic_error_count=1 diagnostic_warning_count=0 tf_proto_version=5.3 tf_req_duration_ms=518 tf_req_id=1ebc0be8-c74d-04ba-bf5f-dc804764ff1d @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/tf5serverlogging/downstream_request.go:40 timestamp=2024-11-08T08:27:32.581Z
2024-11-08T08:27:32.582Z [ERROR] provider.terraform-provider-restapi_v1.20.0: Response contains error diagnostic: @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 tf_proto_version=5.3 tf_req_id=1ebc0be8-c74d-04ba-bf5f-dc804764ff1d tf_provider_addr=provider tf_resource_type=restapi_object tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_detail="" diagnostic_severity=ERROR diagnostic_summary="internal valida

Issue

This error is raised

ERROR diagnostic_summary="internal validation failed; object ID is not set, but *may* have been created; this should never happen"

even through:

  • the REST API seems to have return a 200 response:
2024-11-08T08:27:32.581Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 api_client.go: Response code: 200: timestamp=2024-11-08T08:27:32.581Z
  • the id normalize seems to have been found in the response:
2024-11-08T08:27:32.582Z [INFO]  provider.terraform-provider-restapi_v1.20.0: 2024/11/08 08:27:32 common.go:GetObjectAtKey:  normalize - exists (true): timestamp=2024-11-08T08:27:32.581Z

Would you have any idea on how I could fix this?

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

1 participant