Skip to content

azurerm_api_management_api - should show actual error when imported api definition has errors #29033

Open
hashicorp/go-azure-sdk
#1176
@J0F3

Description

@J0F3

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.11.1

AzureRM Provider Version

4.22.0 (and earlier)

Affected Resource(s)/Data Source(s)

azurerm_api_management_api

Terraform Configuration Files

resource "azurerm_api_management_api" "api" {

  api_management_name = "my-apim"
  resource_group_name = "my-rg"

  name         = "test-tf-error-message"
  display_name = "test-tf-error-message"

  path      = "test/tferror"
  protocols = ["https"]
  revision  = "1"

  service_url = "https://postman-echo.com"

  import {
    content_format = "openapi"
    content_value  = file("openapi.yaml")
  }
}
openapi: 3.0.1
info:
  title: 'test-tf-error-message'
  description: ''
  version: '1.0'
paths:
  /get:
    get:
      summary: get
      operationId: get
      responses:
        '200':
          description: 'get postman echo'
  /testing-2:
    put:
      operationId: test
      summary: get
      responses:
        '200':
          description: 'get postman echo222'
  /testing-3:
    put:
      operationId: test
      summary: get
      responses:
        '200':
          description: 'get postman echo222'

Debug Output/Panic Output

2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: [DEBUG] AzureRM Request: 
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: PUT /subscriptions/{redacted}/resourceGroups/my-rg/providers/Microsoft.ApiManagement/service/my-apim/apis/test-tf-error-message;rev=1?api-version=2022-08-01 HTTP/1.1
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Host: management.azure.com
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: User-Agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 api/2022-08-01) HashiCorp Terraform/1.11.1 (+https://www.terraform.io) terraform-provider-azurerm/4.22.0 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Content-Length: 681
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Accept: application/json; charset=utf-8; IEEE754Compatible=false
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Content-Type: application/json; charset=utf-8
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Odata-Maxversion: 4.0
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Odata-Version: 4.0
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Ms-Correlation-Request-Id: ea7d4f2c-9ed9-8b35-eda9-374e69ad7493
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Accept-Encoding: gzip
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: {"properties":{"apiType":"http","format":"openapi","path":"test/tferror","serviceUrl":"https://postman-echo.com","type":"http","value":"openapi: 3.0.1\ninfo:\n  title: 'test-tf-error-message'\n  description: ''\n  version: '1.0'\npaths:\n  /get:\n    get:\n      summary: get\n      operationId: get\n      responses:\n        '200':\n          description: 'get postman echo'\n  /testing-2:\n    put:\n      operationId: test\n      summary: get\n      responses:\n        '200':\n          description: 'get postman echo222'\n  /testing-3:\n    put:\n      operationId: test\n      summary: get\n      responses:\n        '200':\n          description: 'get postman echo222'\n"}}
2025-03-11T16:11:02.764+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: [DEBUG] PUT https://management.azure.com/subscriptions/{redacted}/resourceGroups/my-rg/providers/Microsoft.ApiManagement/service/my-apim/apis/test-tf-error-message;rev=1?api-version=2022-08-01
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/{redacted}/resourceGroups/my-rg/providers/Microsoft.ApiManagement/service/my-apim/apis/test-tf-error-message;rev=1?api-version=2022-08-01: 
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: HTTP/2.0 400 Bad Request
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Content-Length: 568
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Cache-Control: no-cache
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Content-Type: application/json; charset=utf-8
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Date: Tue, 11 Mar 2025 15:11:03 GMT
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Expires: -1
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Pragma: no-cache
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: Strict-Transport-Security: max-age=31536000; includeSubDomains
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Cache: CONFIG_NOCACHE
2025-03-11T16:11:03.241+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Content-Type-Options: nosniff
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Ms-Correlation-Request-Id: ea7d4f2c-9ed9-8b35-eda9-374e69ad7493
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Ms-Ratelimit-Remaining-Subscription-Global-Writes: 2999
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Ms-Ratelimit-Remaining-Subscription-Writes: 199
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Ms-Request-Id: ea7d4f2c-9ed9-8b35-eda9-374e69ad7493
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Ms-Routing-Request-Id: ITALYNORTH:20250311T151103Z:41093db0-4dc1-4fd6-962f-b6def51f33ab
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: X-Msedge-Ref: Ref A: 43AA2C5B347C4CA9A4EE6B8477ADB12B Ref B: VIEEDGE2211 Ref C: 2025-03-11T15:11:02Z
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5
2025-03-11T16:11:03.242+0100 [DEBUG] provider.terraform-provider-azurerm_v4.22.0_x5: {"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"representation","message":"Parsing error(s): Cannot have multiple operations with the same operationId: test"},{"code":"ValidationError","target":"representation","message":"Parsing error(s): The input OpenAPI file is not valid for the OpenAPI specification https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md (schema https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.yaml)."}]}}
2025-03-11T16:11:03.242+0100 [ERROR] provider.terraform-provider-azurerm_v4.22.0_x5: Response contains error diagnostic: @caller=github.com/hashicorp/terraform-plugin-go@v0.26.0/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_detail="" diagnostic_severity=ERROR tf_provider_addr=registry.terraform.io/hashicorp/azurerm tf_req_id=69a30070-53ae-40ab-ac0e-b38d7ac3c58a tf_resource_type=azurerm_api_management_api tf_rpc=ApplyResourceChange @module=sdk.proto
  diagnostic_summary=
  | creating Api (Subscription: "{redacted}"
  | Resource Group Name: "my-rg"
  | Service Name: "my-apim"
  | Api: "test-tf-error-message;rev=1"): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: ValidationError: One or more fields contain incorrect values:

Expected Behaviour

The error message should display the specific error details returned by the Azure API, rather than just the generic message: "Unexpected status 400 (400 Bad Request) with error: ValidationError: One or more fields contain incorrect values."

Actual Behaviour

The output is not helpful for debugging or identifying the actual problem. It merely states, "ValidationError: One or more fields contain incorrect values," but the valuable information that follows the colon is absent. This omission complicates the debugging process unnecessarily.

Steps to Reproduce

  1. Apply the above configuration which tries to import an invalid openapi.yaml

Important Factoids

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions