Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXEC : error | error : spawn EINVAL #4968

Open
2 tasks done
archerzz opened this issue May 21, 2024 · 5 comments
Open
2 tasks done

EXEC : error | error : spawn EINVAL #4968

archerzz opened this issue May 21, 2024 · 5 comments
Assignees

Comments

@archerzz
Copy link
Member

Before filling a bug

  • have you checked the faq for known issues.
  • have you checked existing issues

Describe the bug

Starting from May 17, there were autorest errors in one of our pipeline: https://dev.azure.com/azure-sdk/internal/_build?definitionId=5990&_a=summary

fatal | Process() cancelled due to failure
EXEC : error | error : spawn EINVAL [D:\a\_work\1\s\azure-sdk\sdk\resourcehealth\Azure.ResourceManager.ResourceHealth\src\Azure.ResourceManager.ResourceHealth.csproj]
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.
C:\Users\cloudtest\.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-alpha.20240519.1\buildMultiTargeting\Microsoft.Azure.AutoRest.CSharp.targets(57,5): error MSB3073: The command "npx autorest@ --max-memory-size=8192 --skip-csproj --skip-upgrade-check --version=3.9.7 D:\a\_work\1\s\azure-sdk\sdk\resourcehealth\Azure.ResourceManager.ResourceHealth\src/autorest.md --use=C:\Users\cloudtest\.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-alpha.20240519.1\buildMultiTargeting\../tools/net7.0/any/ --clear-output-folder=true --shared-source-folders="D:\a\_work\1\s\azure-sdk\eng\/../sdk/core/Azure.Core/src/Shared/;C:\Users\cloudtest\.nuget\packages\microsoft.azure.autorest.csharp\3.0.0-alpha.20240519.1\buildMultiTargeting\../content/Generator.Shared/" --output-folder=D:\a\_work\1\s\azure-sdk\sdk\resourcehealth\Azure.ResourceManager.ResourceHealth\src/Generated --namespace=Azure.ResourceManager.ResourceHealth" exited with code 1. [D:\a\_work\1\s\azure-sdk\sdk\resourcehealth\Azure.ResourceManager.ResourceHealth\src\Azure.ResourceManager.ResourceHealth.csproj]

After analysis, we thought it's due to a security enhancement introduced in node v18.20.2: nodejs/node#52554
The fix is to pass { shell: true } when invoking spawn(). I searched the codes of autorest, and I found there are several invocation of spawn(). I guess they are for invoking generators. Can we have an alpha build so that we can try on our pipeline to verify the fix?

Expected behavior
autorest should run without error on Windows server 2022 + node v18.20.2

Additional context

@hallipr
Copy link
Member

hallipr commented May 21, 2024

A minimal readme.md to repro the EINVAL is:

use-extension:
  "@microsoft.azure/classic-openapi-validator": "~1.1.5"
input-file: sample.yaml

ResourceHealth's config is getting this through:

azure-validator: true

This imports classic-openapi-validator if we don't also set v3: true

A workaround is to add v3: true to the affected autorest config.

@ryanrivest
Copy link

We are running into this error as well. We are using the legacy C# generator, so the v3: true flag does not work in our case. Any suggestions for a different workaround?

Here is another repro:

input-file: https://github.com/Azure/azure-rest-api-specs/blob/d374d03801e97737ddb32e01f20513e7b2bbd9c3/arm-storage/2015-06-15/swagger/storage.json
csharp: true
legacy: true

@keremaytac
Copy link

Well, if legacy one is still needed, and if your problem persists in your build pipelines, the only workaround could be changing your build agent to a linux one (i.e. ubuntu-latest) from windows (windows-latest).

That worked for my case.

@mikeharder
Copy link
Member

I think it should be easy to review our usage of spawn(), and add { shell: true } where needed.

@mikeharder mikeharder moved this from 🐝 Dev to 📋 Backlog in Azure SDK EngSys 🤖🧠 Jan 21, 2025
@mikeharder
Copy link
Member

This might be a minimal repro? Linux also fails, but with a different error.

Windows

> npx autorest --input-file="foo.json" --azure-validator

AutoRest code generation utility [cli version: 3.7.1; node: v20.18.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ~2.0.4413.
   Loading AutoRest core      'C:\Users\mharder\.autorest\@[email protected]\nodemodules\@microsoft.azure\autorest-core\dist' (2.0.4429)
   Loading AutoRest extension '@microsoft.azure/classic-openapi-validator' (~1.0.9->1.0.14)
   Loading AutoRest extension '@microsoft.azure/openapi-validator' (~1.0.2->1.0.4)
Process() cancelled due to exception : spawn EINVAL
  Error: spawn EINVAL

Linux

$ npx autorest --input-file="foo.json" --azure-validator
AutoRest code generation utility [cli version: 3.7.1; node: v22.13.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ~2.0.4413.
(node:253096) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
installing core... [========================================] 100% | 2/2
   Loading AutoRest core      '/home/mharder/.autorest/@[email protected]/nodemodules/@microsoft.azure/autorest-core/dist' (2.0.4429)
(node:253127) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
   Installing AutoRest extension '@microsoft.azure/classic-openapi-validator' (~1.0.9)
   Installing AutoRest extension '@microsoft.azure/openapi-validator' (~1.0.2)
FailFast: Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

5 participants