Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
140 stars 160 forks source link

Error: spawn EINVAL running autorest legacy on windows #4676

Open jwaltz-bah opened 2 months ago

jwaltz-bah commented 2 months ago

A recent Node JS update includes a breaking change to patch a security vulnerability: https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2

When running autorest csharp v2 on Windows, the "spanw EINVAL" error occurs and stops execution.

Tested with both Node v21.7.3 and v18.20.2 (the patch was applied across all major Node versions)

Command:

autorest --input-file=swagger.json --csharp --legacy --add-credentials --namespace=MyApp.Model.Data --output-folder=MyApp.Model\Data

Console output:

AutoRest code generation utility [cli version: 3.7.1; node: v21.7.3]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ~2.0.4413.
   Loading AutoRest core      'C:\Users\me\.autorest\@microsoft.azureautorest-core@2.0.4429\nodemodules\@microsoft.azure\autorest-core\dist' (2.0.4429)
No configuration found at 'file:///C:/Users/me/repos/PPIThePricingAppIntegration/PricingApp/'.
   Loading AutoRest extension '@microsoft.azure/autorest.csharp' (~2.3.79->2.3.102)
   Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55)
Process() cancelled due to exception : spawn EINVAL
  Error: spawn EINVAL

Suggested solution from the Security Release announcement:

If the input to spawn/spawnSync is sanitized, users can now pass { shell: true } as an option to prevent the occurrence of EINVALs errors.

jwaltz-bah commented 2 months ago

Should be labeled v2--haven't tested on v3