Skip to content

DscConfigurationClient.GetContent is broken since 2020-01-13-preview/automation API version #17591

@dz-sourced

Description

@dz-sourced

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:

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:

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.

Metadata

Metadata

Assignees

Labels

AutomationMgmtThis issue is related to a management-plane library.Previous VersionsWork related to track1 and track1.5 SDKsService AttentionWorkflow: This issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions