Azure / autorest.powershell

AutoRest PowerShell Generator
MIT License
111 stars 76 forks source link

TypeError: Cannot read properties of undefined (reading 'fullName') #1160

Closed meichhorn-conet closed 2 weeks ago

meichhorn-conet commented 1 year ago

Getting the following error:

/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/dist/plugins/llcsharp-v2.js - TypeError: Cannot read properties of undefined (reading 'fullName')
    at ModelClass.handleAllOf (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/model-class.ts:413:37)
    at new ModelClass (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/model-class.ts:142:15)
    at ModelsNamespace.NewResolveTypeDeclaration (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/namespace.ts:104:67)
    at new ModelsNamespace (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/namespace.ts:53:14)
    at Project.init (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/project.ts:85:28)
    at llcsharpV2 (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/plugins/llcsharp-v2.ts:18:21)
    at /root/.autorest/@autorest_powershell@3.0.504/node_modules/@azure-tools/autorest-extension-base/extension-base.ts:68:9/Cannot read properties of undefined (reading 'fullName')
PLUGIN FAILURE: Cannot read properties of undefined (reading 'fullName'), TypeError: Cannot read properties of undefined (reading 'fullName')
    at ModelClass.handleAllOf (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/model-class.ts:413:37)
    at new ModelClass (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/model-class.ts:142:15)
    at ModelsNamespace.NewResolveTypeDeclaration (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/namespace.ts:104:67)
    at new ModelsNamespace (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/model/namespace.ts:53:14)
    at Project.init (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/llcsharp/project.ts:85:28)
    at llcsharpV2 (/root/.autorest/@autorest_powershell@3.0.504/node_modules/@autorest/powershell/plugins/llcsharp-v2.ts:18:21)
    at /root/.autorest/@autorest_powershell@3.0.504/node_modules/@azure-tools/autorest-extension-base/extension-base.ts:68:9, {}
fatal   | TypeError: Cannot read properties of undefined (reading 'fullName')
dolauli commented 1 year ago

@meichhorn-conet Would you provide more details about how to reproduce the issue?

meichhorn-conet commented 1 year ago

How can I turn on advanced logging so that i can see which class is current processed and leads to this error?

dolauli commented 1 year ago

How can I turn on advanced logging so that i can see which class is current processed and leads to this error?

Not just logs. I need steps to reproduce issue. Generally speaking please provider swagger, and how you generate the module.

bgrossman commented 1 year ago

First time using AutoRest, getting the error too. Using this OpenAPI spec. Generating with:

autorest --powershell --input-file:openapi.json --output-folder:foo

meichhorn-conet commented 1 year ago

@dolauli In my case, i cannot share the whole schema.json because this a private api.

The stacktrace says a single class cant be generated. With that class name, i can try reproduce this error with a simple api and without ip.

how can i turn on this log to get the class name?

dolauli commented 1 year ago

@dolauli In my case, i cannot share the whole schema.json because this a private api.

The stacktrace says a single class cant be generated. With that class name, i can try reproduce this error with a simple api and without ip.

how can i turn on this log to get the class name?

Log will not help lot here. You will not need to provide your private swagger to me, but you could just write a swagger that could reproduce the issue and meanwhile hiding your business info.

elonmallin commented 10 months ago

I'm getting basically the same error for this Azure DevOps Artifacts Feed swagger.

I run this command autorest --input-file=feed.json --powershell --verbose

I get this error:

C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\dist\plugins\llcsharp-v2.js - TypeError: Cannot read property 'fullName' of undefined
    at ModelClass.handleAllOf (C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\llcsharp\model\model-class.ts:413:37)   
    at new ModelClass (C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\llcsharp\model\model-class.ts:142:15)
    at ModelsNamespace.NewResolveTypeDeclaration (C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\llcsharp\model\namespace.ts:104:67)
    at new ModelsNamespace (C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\llcsharp\model\namespace.ts:53:14)
    at Project.init (C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\llcsharp\project.ts:85:28)
    at llcsharpV2 (C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@autorest\powershell\plugins\llcsharp-v2.ts:18:21)
    at C:\Users\atodw\.autorest\@autorest_powershell@3.0.510\node_modules\@azure-tools\autorest-extension-base\extension-base.ts:68:9/Cannot read property 'fullName' of undefined
fatal   | TypeError: Cannot read property 'fullName' of undefined
fatal   | Process() cancelled due to failure 
error   |   Error: Plugin llcsharp-v2 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.

Is there some way to get a better error message? I feel like it's common to get errors but not sure if it's the tool or the swaggers/openapi specs that are at fault. Either way it would be nice if the tool didn't crash if it can't complete everything, if just one route or model is wrong in the whole spec then it could be a warning instead perhaps?