Skip to content

armresources.DeploymentsClient Validate always returns "the operation failed or was cancelled" not the actual error #24274

@matthchr

Description

@matthchr

Bug Report

The BeginValidate function of DeploymentsClient doesn't correctly return errors.

  • import path of package in question, e.g. "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
  • SDK version: 1.2.0

I believe that this is because the service defines the following in its Swagger for this operation:

        "responses": {
          "200": {
            "description": "OK - Returns the validation result.",
            "schema": {
              "$ref": "#/definitions/DeploymentValidateResult"
            }
          },
          "202": {
            "description": "Accepted - The request has been accepted for processing and the operation will complete asynchronously."
          },
          "400": {
            "description": "Returns the validation result.",
            "schema": {
              "$ref": "#/definitions/DeploymentValidateResult"
            }
          },

This results in HTTP 400 not producing an error, here

Which then ends up hitting this code:

	// this is a back-stop in case the swagger is incorrect (i.e. missing one or more status codes for success).
	// ideally the codegen should return an error if the initial response failed and not even create a poller.
	if !poller.StatusCodeValid(resp) {
		return nil, errors.New("the operation failed or was cancelled")
	}

The result: Any failed deployment validate will never report any error except "the operation failed or was cancelled".

Metadata

Metadata

Assignees

Labels

MgmtThis issue is related to a management-plane library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions