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

az command returns 0 when failing #23880

Closed
fuhuifang opened this issue Sep 14, 2022 · 8 comments
Closed

az command returns 0 when failing #23880

fuhuifang opened this issue Sep 14, 2022 · 8 comments
Assignees
Labels
CXP Attention This issue is handled by CXP team. Machine Learning az ml

Comments

@fuhuifang
Copy link
Member

Related command
az extension show -n azure-ml-cli

Describe the bug
When azure-ml-cli is not installed, we expect an error with exitcode 1. This works properly for 2.39 and older, but with 2.40, it returns 0.

To Reproduce
Run the following python script:

import subprocess
subprocess.run(args=['pwsh', '-EncodedCommand', 'YQB6ACAAZQB4AHQAZQBuAHMAaQBvAG4AIABzAGgAbwB3ACAALQBuACAAYQB6AHUAcgBlAC0AYwBsAGkALQBtAGwA'])

Outputs
2.40
image
2.39
image

Expected behavior
CompletedProcess(args=['pwsh', '-EncodedCommand', 'YQB6ACAAZQB4AHQAZQBuAHMAaQBvAG4AIABzAGgAbwB3ACAALQBuACAAYQB6AHUAcgBlAC0AYwBsAGkALQBtAGwA'], returncode=1)

Environment summary
Windows, python 3.8

Additional context
Similar to #23808

@yonzhan yonzhan added Machine Learning az ml CXP Attention This issue is handled by CXP team. labels Sep 14, 2022
@ghost
Copy link

ghost commented Sep 14, 2022

Thank you for your feedback. This has been routed to the support team for assistance.

@yonzhan
Copy link
Collaborator

yonzhan commented Sep 14, 2022

route to CXP team

@yjm607
Copy link

yjm607 commented Sep 14, 2022

Hi Yong, will there be an IcM ticket filed for this issue? It is affecting all customers of the Substrate Intelligence AI platform and the Shrike library.

@jiasli
Copy link
Member

jiasli commented Sep 30, 2022

This looks like some issue with PowerShell.

Say we have the same test.cmd and test.ps1:

test.ps1:

python -c "exit(1)"

test.cmd:

@echo off
python -c "exit(1)"

The exit code is correct when they are invoked directly:

PS D:\> ./test.cmd ; echo $LASTEXITCODE
1
PS D:\> ./test.ps1 ; echo $LASTEXITCODE
1

However, when invoked by pwsh.exe, they return different result:

PS D:\> pwsh -Command "./test.cmd" ; echo $LASTEXITCODE
1
PS D:\> pwsh -Command "./test.ps1" ; echo $LASTEXITCODE
0

If test.ps1 contains

Exit 1

It works as expected:

PS D:\> ./test.ps1 ; echo $LASTEXITCODE
1
PS D:\> pwsh -Command "./test.ps1" ; echo $LASTEXITCODE
1

Azure CLI switched to az.ps1 in #23514, leading to this problem.

@jiasli
Copy link
Member

jiasli commented Sep 30, 2022

On contrary, cmd.exe works as expected:

D:\>test.cmd & echo %ErrorLevel%
1
D:\>cmd.exe /c "test.cmd" & echo %ErrorLevel%
1

So does Bash:

user2@DESKTOP-A79F1:~$ ./test.sh ; echo $?
1
user2@DESKTOP-A79F1:~$ bash -c "./test.sh" ; echo $?
1

@jiasli
Copy link
Member

jiasli commented Sep 30, 2022

We will revert the change in #24015

@saisankargochhayat
Copy link

Also facing the same issue, looking forward to the next release fixing this issue!

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 4, 2022

https://github.com/Azure/azure-cli/milestone/122 Build to Cloud Shell: 10/10/2022 Official Release: 10/12/2022

@jiasli jiasli closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CXP Attention This issue is handled by CXP team. Machine Learning az ml
Projects
None yet
Development

No branches or pull requests

5 participants