Azure / Azure/azure-rest-api-specs
Autorest generation failure for cosmos-db, property name "Type" is not allowed
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 3d 37m
- Merged PRs (30d)
- 446
Description
Autorest generation of package-2023-03 and later is failing with internal error in AutoRest.CSharp.
autorest https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/cosmos-db/resource-manager/readme.md --azure-arm --csharp --csharp.clear-output-folder=false --csharp.output-folder=D:\src\git\AD\Platform\Components\src\lib\AzureSdk\Generated\CosmosDb --tag=package-2023-04 --csharp.namespace=Microsoft.Azure.Management.CosmosDb
fatal | Internal error in AutoRest.CSharp
Please file an issue at https://github.com/Azure/autorest.csharp/issues/new.
Attach the written 'Configuration.json' and 'CodeModel.yaml' or the original swagger so we can reproduce your error.
Exception: DatabaseAccountConnectionString has a property named "Type" which is not allowed. Please use "x-ms-client-name" to rename the property for the client.
at AutoRest.CSharp.Mgmt.Decorator.Transformer.FrameworkTypeUpdater.ValidateAndUpdate() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Mgmt\Decorator\Transformer\FrameworkTypeUpdater.cs:line 46
at AutoRest.CSharp.Mgmt.Decorator.CodeModelTransformer.Transform() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Mgmt\Decorator\CodeModelTransformer.cs:line 26
at AutoRest.CSharp.Mgmt.AutoRest.MgmtOutputLibrary..ctor() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Mgmt\AutoRest\MgmtOutputLibrary.cs:line 102
at AutoRest.CSharp.Output.Models.Types.BuildContext`1.EnsureLibrary() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\Types\BuildContextOfT.cs:line 31
at AutoRest.CSharp.AutoRest.Plugins.MgmtTarget.ExecuteAsync(GeneratedCodeWorkspace project, CodeModel codeModel, SourceInputModel sourceInputModel) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Mgmt\AutoRest\MgmtTarget.cs:line 66
at AutoRest.CSharp.AutoRest.Plugins.CSharpGen.ExecuteAsync(CodeModel codeModel) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\AutoRest\Plugins\CSharpGen.cs:line 43
at AutoRest.CSharp.AutoRest.Plugins.CSharpGen.Execute(IPluginCommunication autoRest) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\AutoRest\Plugins\CSharpGen.cs:line 98
fatal | Process() cancelled due to failure
error | Error: Plugin csharpgen reported failure.
error | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
Contributor guide
Research direction
Start with AutoRest.CSharp/Mgmt/Decorator/Transformer/FrameworkTypeUpdater.cs at line 46 and the Cosmos DB readme used for the package-2023-04 generation. Reproduce the command, inspect the DatabaseAccountConnectionString definition, and verify that generation completes without the forbidden property error. Done means the generated package succeeds with the property represented by an allowed client name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100