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

Deployment validation and create does not return error #6125

Closed
itavy opened this issue Oct 23, 2019 · 9 comments
Closed

Deployment validation and create does not return error #6125

itavy opened this issue Oct 23, 2019 · 9 comments
Assignees
Labels
ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. Service Attention This issue is responsible by Azure service team.

Comments

@itavy
Copy link

itavy commented Oct 23, 2019

Bug Report

  • import path of package in question: .../services/resources/mgmt/2018-05-01/resources
  • SDK versio: v34.2.0
  • output of go version:
go version go1.13.3 darwin/amd64

i followed steps in example sdk to make a deployment
both Validate and CreateOrUpdate methods of DeploymentClient return no error, although the site responds back with 400 status code:

...
(2019-10-23T09:49:01.5103070+03:00) INFO: REQUEST: POST https://management.azure.com/subscriptions/xxxxx/resourcegroups/xxxxx/providers/Microsoft.Resources/deployments/xxxxx/validate?api-version=2018-05-01
...

(2019-10-23T09:49:02.7478530+03:00) INFO: RESPONSE: 400 https://management.azure.com/subscriptions/xxxx/resourcegroups/xxxx/providers/Microsoft.Resources/deployments/xxxx/validate?api-version=2018-05-01
.....
{"error":{"code":"InvalidTemplate","message":"Deployment template validation failed: 'The template variable 'var_allowedCallerIpAddresses' is not valid: The language expression property 'cidr' can't be evaluated.. Please see https://aka.ms/arm-template-expressions for usage details.'.","additionalInfo":[{"type":"TemplateViolation","info":{"lineNumber":1,"linePosition":4613,"path":"properties.template.variables.var_allowedCallerIpAddresses"}}]}}
(2019-10-23T09:49:02.7491100+03:00) INFO: REQUEST: PUT https://management.azure.com/subscriptions/xxxxxx/resourcegroups/xxxxx/providers/Microsoft.Resources/deployments/xxxxx?api-version=2018-05-01
...

(2019-10-23T09:49:03.5755030+03:00) INFO: RESPONSE: 400 https://management.azure.com/subscriptions/xxxx/resourcegroups/xxxx/providers/Microsoft.Resources/deployments/xxxx?api-version=2018-05-01
...
{"error":{"code":"InvalidTemplate","message":"Deployment template validation failed: 'The template variable 'var_allowedCallerIpAddresses' is not valid: The language expression property 'cidr' can't be evaluated.. Please see https://aka.ms/arm-template-expressions for usage details.'.","additionalInfo":[{"type":"TemplateViolation","info":{"lineNumber":1,"linePosition":4613,"path":"properties.template.variables.var_allowedCallerIpAddresses"}}]}}

it seems the problem is this line

because it doesn't throw error in case of Bad request

it seems it is related to definition in Azure Rest Api specs and autorest generator which treats all responses defined in api as expected responses and does not throw error

this behaviour is the same in other api versions

Thanks!
Octavian

@loarabia loarabia added ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. labels Oct 23, 2019
@itavy
Copy link
Author

itavy commented Oct 25, 2019

as for this suggestion we can use this workaround although the error returned from the site you cannot be sure it is because of template or because you didn't send proper request

for this it will be clear if the examples are updated to check for response error instead of relying on sdk trigger the error WDYT?

Regards,
Octavian

@ArcturusZhang
Copy link
Member

A fix for this issue (if needed) will need the service team to come in. I have tagged this issue so the right team will see.

@ArcturusZhang ArcturusZhang added the Service Attention This issue is responsible by Azure service team. label Oct 28, 2019
@ghost
Copy link

ghost commented Oct 28, 2019

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure

@alex-frankel
Copy link

@itavy is the issue that the SDK does not return an error? Or is that you can't distinguish between a poorly authored template and a malformed request because they both return 4xx?

@itavy
Copy link
Author

itavy commented Oct 28, 2019

my issue was the fact i cannot distinguish between 2 cases; but this was not my initial problem, but the actual example sdk that is misleading

so after investigating this a bit more there are 2 issues:

  1. misleading documentation
  2. no options to distinguish between an invalid template and a malformed request

@itavy
Copy link
Author

itavy commented Oct 28, 2019

btw they return 400 code, not any 4xx code. for any other 4xx request except 400 it will rise an error

@alex-frankel
Copy link

We just had a discussion about this.

You are right that the issue is in the autorest logic, but to make a change there would be a significant breaking change. Since you have a workaround to parse the error object to see if a 400 is present, we don't feel we need to make a breaking change like that at this time.

We will take an action to update the example sdk that you linked to. We agree it is misleading. Once the example is updated, we will link to that in this issue.

For distinguishing the 400s, that is again something we are not able to change at this time. When you submit a deployment via the API, the template itself is in the PUT body, so if there is something wrong with the template it is correctly being categorized as a bad request. You should be able to base your logic off of the error details that are returned.

Does this all make sense? After your response I will close the issue.

@itavy
Copy link
Author

itavy commented Oct 28, 2019 via email

@ghost
Copy link

ghost commented Oct 29, 2019

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants