Autorest: Autorest search "readme.md" outside of current folder

Created on 17 Jul 2017  路  4Comments  路  Source: Azure/autorest

I execute this command (I leave my current working folder on purpose):

cd ~\Git\azure-rest-api-specs\specification\compute\resource-manager\Microsoft.ContainerService\2017-01-31

autorest --azure-arm=True --input-file=C:\Users\lmazuel\Git\azure-rest-api-specs\specification\compute\resource-manager\Microsoft.ContainerService\2017-01-31\containerService.json --license-header=MICROSOFT_MIT_NO_VERSION --namespace=azure.mgmt.compute.containerservice.v2017_01_31 --payload-flattening-threshold=2 --python

And autorest is reading the MD in C:\Users\lmazuel\Git\azure-rest-api-specs\specification\compute\resource-manager!!

I understand that it reads the MD in the current working folder, but looking this file somewhere in the hierarchy is too much, and prevents me to generate this file.

(autorest 1.2.2)

Most helpful comment

I'd disable the upward traversal. I received more questions/complaints like this, it's not very intuitive what happens there. That would also eliminate the need to tweak any paths and what they are relative to. (Note that stuff is relative to the base folder since CLI args are treated the same way as configuration file content)

All 4 comments

A local path to input-file creates a weird error:

autorest --azure-arm=True --input-file=containerService.json --license-header=MICROSOFT_MIT_NO_VERSION --namespace=azure.mgmt.compute.containerservice.v2017_01_31 --payload-flattening-threshold=2 --python
AutoRest Code Generator
(c) 2017 Microsoft Corporation. https://aka.ms/autorest
FATAL: swagger-document-override/md-override-loader - FAILED
FATAL: Error: Failed to read 'file:///C:/Users/lmazuel/Git/azure-rest-api-specs/specification/compute/resource-manager/containerService.json'. Key not found.
FATAL: swagger-document/loader - FAILED
FATAL: Error: Failed to read 'file:///C:/Users/lmazuel/Git/azure-rest-api-specs/specification/compute/resource-manager/containerService.json'. Key not found.
Process() Cancelled due to exception : Failed to read 'file:///C:/Users/lmazuel/Git/azure-rest-api-specs/specification/compute/resource-manager/containerService.json'. Key not found.
Error: Failed to read 'file:///C:/Users/lmazuel/Git/azure-rest-api-specs/specification/compute/resource-manager/containerService.json'. Key not found.
    at DataStoreViewReadThroughFS.<anonymous> (C:\Users\lmazuel\.autorest\plugins\autorest\1.2.2\node_modules\autorest-core\lib\data-store\data-store.js:27:23)
    at next (native)
    at fulfilled (C:\Users\lmazuel\AppData\Roaming\npm\node_modules\autorest\lib\polyfill.min.js:14:62)

Seems like cwd is changed to where is found readme.md.

Yeah, we've got some aggressive behavior in there.

At the very least, we should make sure that we can tell it not to look for a config file.

And you're right, input-file on the command line should be relative to the CWD instead of the base-folder. Hmm. That could be interesting.

I'd disable the upward traversal. I received more questions/complaints like this, it's not very intuitive what happens there. That would also eliminate the need to tweak any paths and what they are relative to. (Note that stuff is relative to the base folder since CLI args are treated the same way as configuration file content)

note to self: add setting whether or not to traverse up - defaults to false, set to true by VSCode extension

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinoid picture kevinoid  路  6Comments

VitaliyKurokhtin picture VitaliyKurokhtin  路  6Comments

lmazuel picture lmazuel  路  3Comments

vishrutshah picture vishrutshah  路  4Comments

pbolduc picture pbolduc  路  7Comments