-
Notifications
You must be signed in to change notification settings - Fork 955
Description
Bug Report
Summary:
When trying to read back a DSC Configuration content using func (client DscConfigurationClient) GetContent an error happens in the version of the API 2020-01-13-preview/automation and later while trying to unmarshall DSC Configuration content from JSON. DSC Configurations are not valid JSON objects and thus unmarshalling fails. This issue was not happening in 2018-06-30-preview/automation and earlier, where DSC Configuration content was treated as a plain string value. I have confirmed the issue on the main branch.
Details:
In the 2020-01-13-preview/automation the actual failure seems to happen when trying to unmarshall DSC Configuration content from JSON:
azure-sdk-for-go/services/preview/automation/mgmt/2020-01-13-preview/automation/dscconfiguration.go
Line 384 in 94316ba
| autorest.ByUnmarshallingJSON(&result.Value), |
The error that I get when trying to read back a sample DSC Configuration like Configuration test {} is:
automation.DscConfigurationClient#GetContent: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'invalid character 'C' looking for beginning of value' JSON = 'Configuration test{}'
This was not happening in the previous version of the API 2018-06-30-preview/automation and the content value was just passed as is:
azure-sdk-for-go/services/preview/automation/mgmt/2018-06-30-preview/automation/dscconfiguration.go
Line 383 in 94316ba
| resp, |
Finally, the root cause can be traced to the change in the Swagger API definitions. The latest version of the GetContent API defines the output as a string type, which I assume is tried to be de-serialized from JSON by default:
https://github.com/Azure/azure-rest-api-specs/blob/3034ada77d465b317cda51250a92454824cca06b/specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/dscConfiguration.json#L309
In the earlier version of the API spec the output type is set to file:
https://github.com/Azure/azure-rest-api-specs/blob/3026119ab41bbce77275cfa3a1afbabf43af5aea/specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/dscConfiguration.json#L309
I don't know whether this was intentional API spec change, or whether there is a need to provide further type modifiers in the Swagger API or whether it's an issue with the SDK codegen tool.
Here is a small script that demostrates the problem https://gist.github.com/dz-sourced/11654206078fcc159c54564de6758659
It creates a resource group, an automation account, a sample empty DSC Configuration and the tries to read it using older and new API versions. You should be able to see that read is succesful in 2018-06-30-preview/automation and fails in the 2020-01-13-preview/ version.