Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
83 stars 26 forks source link

Incorrect 'RequestIsNotValidJson' error from storage RP due to null value on property #1334

Open Ausxor opened 1 year ago

Ausxor commented 1 year ago

Bicep version az bicep version: Bicep CLI version 0.14.6 (f1dae160cd) azure-cli 2.44.1

Describe the bug When deploying ARM template to create an Azure Storage account, incorrect error 'RequestIsNotValidJson' is produced if 'null' value passed to 'bypass' property of networkAcls. The error is incorrect as the transpiled JSON is valid in the request body to ARM. VSCode also does not validate the 'null' value as incorrect in linting.

To Reproduce Steps to reproduce the behavior:

  1. Download main.bicep.txt and rename to *.bicep.
  2. Run CLI command: az deployment group create --resource-group <resource_group> --template-file "main.bicep"

Actual: Error received: BadRequest .. RequestIsNotValidJson ... The request cannot be interpreted as valid Json

{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": \"RequestIsNotValidJson\",\r\n    \"message\": \"The request cannot be interpreted as valid Json: {\\\"sku\\\":{\\\"name\\\":\\\"Standard_LRS\\\"},\\\"kind\\\":\\\"StorageV2\\\",\\\"location\\\":\\\"australiaeast\\\",\\\"properties\\\":{\\\"supportsHttpsTrafficOnly\\\":true,\\\"networkAcls\\\":{\\\"bypass\\\":null,\\\"defaultAction\\\":\\\"Deny\\\",\\\"ipRules\\\":[],\\\"virtualNetworkRules\\\":[],\\\"resourceAccessRules\\\":[]}}}.\"\r\n  }\r\n}"}]}}

Expected

Additional context Raised by MSFT. Internal logs show the response is coming from the Microsoft.Storage resource provider.

stephaniezyen commented 1 year ago

This is a resource provider bug, please create a support ticket for this issue.

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage. Please see https://aka.ms/biceptypesinfo for troubleshooting help.

Issue Details
**Bicep version** az bicep version: Bicep CLI version 0.14.6 (f1dae160cd) azure-cli 2.44.1 **Describe the bug** When deploying ARM template to create an Azure Storage account, incorrect error 'RequestIsNotValidJson' is produced if 'null' value passed to 'bypass' property of networkAcls. The error is incorrect as the transpiled JSON is valid in the request body to ARM. VSCode also does not validate the 'null' value as incorrect in linting. - The error is caused by passing null to 'bypass'. If this property is commented out the template will work. ![image](https://user-images.githubusercontent.com/4426330/215953107-445d4b5f-2bcc-4ab4-9b48-0b26943b546c.png) **To Reproduce** **Steps to reproduce the behavior:** 1. Download [main.bicep.txt](https://github.com/Azure/bicep/files/10553376/main.bicep.txt) and rename to *.bicep. 2. Run CLI command: `az deployment group create --resource-group --template-file "main.bicep"` **Actual:** Error received: BadRequest .. RequestIsNotValidJson ... The request cannot be interpreted as valid Json ``` {"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"RequestIsNotValidJson\",\r\n \"message\": \"The request cannot be interpreted as valid Json: {\\\"sku\\\":{\\\"name\\\":\\\"Standard_LRS\\\"},\\\"kind\\\":\\\"StorageV2\\\",\\\"location\\\":\\\"australiaeast\\\",\\\"properties\\\":{\\\"supportsHttpsTrafficOnly\\\":true,\\\"networkAcls\\\":{\\\"bypass\\\":null,\\\"defaultAction\\\":\\\"Deny\\\",\\\"ipRules\\\":[],\\\"virtualNetworkRules\\\":[],\\\"resourceAccessRules\\\":[]}}}.\"\r\n }\r\n}"}]}} ``` **Expected** - On inspection of the request body (using --debug) the JSON sent to ARM is valid. The error message is misleading. I would expect the error message to not identify the JSON as invalid, and instead identify the 'bypass' field as producing the issue. - Visual Studio Code does not identify the field as invalid, I would expect it to validate against the schema to identify users of the issue prior to deployment. ![image](https://user-images.githubusercontent.com/4426330/215953749-e92fd89c-1bc9-45d7-83f0-925514586b65.png) **Additional context** Raised by MSFT. Internal logs show the response is coming from the Microsoft.Storage resource provider.
Author: Ausxor
Assignees: -
Labels: `Service Attention`, `Storage`
Milestone: -