question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autorest python failing for x-ms-pageable extension while passing for CSharp

See original GitHub issue

Input Json: https://github.com/Azure/azure-rest-api-specs/blob/master/arm-recoveryservicesbackup/2016-12-01/swagger/backupManagement.json Autorest version: 1.0.1-20170517-2300-nightly

Failure error:

FATAL: System.Collections.Generic.KeyNotFoundException: Couldn't find the item property specified by extension
   at AutoRest.Python.Azure.TransformerPya.GetPagingSetting(CodeModelPya codeModel, CompositeType body, Dictionary`2 extensions, String valueTypeName, IDictionary`2 typePageClasses, String methodName)
   at AutoRest.Python.Azure.TransformerPya.NormalizePaginatedMethods(CodeModelPya codeModel)
   at AutoRest.Python.Azure.TransformerPya.TransformCodeModel(CodeModel cm)
   at Generator.<ProcessInternal>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NewPlugin.<Process>d__11.MoveNext()
FATAL: python/generate - FAILED
Process() Cancelled due to exception : Plugin python reported failure.
Error: Plugin python reported failure.
    at C:\Users\dhratho\.autorest\plugins\autorest\1.0.1-20170517-2300-nightly\node_modules\autorest-core\lib\pipeline\pipeline.js:88:19
    at next (native)
    at fulfilled (C:\Users\dhratho\AppData\Roaming\npm\node_modules\autorest\lib\polyfill.min.js:10:59)
    at process._tickCallback (internal/process/next_tick.js:109:7)

This error is coming for Python generator while working fine for CSharp generator.

Diagnostics:

  • In paths with operation_id Operations_List, response schema name is ClientDiscoveryResponse which is pageable and hence NextLink and Value fields are present in schema.
  • In schema properties NextLink and Value are present, but python generator is looking for “value” field which is not present and hence failing. (Autorest.Python.Azure TransformerPya.cs#129).
  • But on the other hand in CSharp generator (Autorest.CSharp.Azure TransformerCsa.cs#184 GetPagingSetting) no such check is present.
  • On further analysis it turns out that this check is present only in Python generator, which presents inconsistency across generator transformers.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
olydiscommented, Jun 1, 2017

Shouldn’t be a linter rule that check itemName content or value is in the Swagger?

excellent idea, I’ll file an issue!

1reaction
DheerendraRathorcommented, Jun 1, 2017

@olydis C# generator doesn’t check whether property with itemName actually exists. Surprising thing is only Python generator is making this check and even Python generator is missing check for nextLinkName (though code exists, it is just not enforcing check).

I believe python is making these checks as in-built json module in python is case sensitive.

Although this can be made consistent across languages by adding these checks appropriately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AutoRest Extensions for OpenAPI 2.0 - Azure documentation
Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python. ... Microsoft Azure Extensions (available in most generators only when using --azure-arm ).
Read more >
@autorest/azure-functions-python - npm
The Azure Functions extension for code generators in AutoRest.. Latest version: 0.1.0-preview, last published: 2 years ago.
Read more >
rest - How to downgrade Autorest extensions - specifically C# ...
I am using Autorest to generate C# code from an OpenAPI YAML file. I tried to upgrade the Autorest C# extension to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found