Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
402 stars 195 forks source link

[Issue] `azd hooks run` not respecting `interactive` configuration #4382

Open cedricvidal opened 5 days ago

cedricvidal commented 5 days ago

Output from azd version Run azd version and copy and paste the output here:

azd version 1.10.1 (commit 31409a33266fb4a5fdbb644bc83988e725d6c7c9)

Describe the bug azd hooks don't get TTY in interactive mode on linux/sh and linux/pwsh

Github repo with code to reproduce https://github.com/cedricvidal/azd-hook-interactive-python

This limits the possibility to provide a nice interactive onboarding experience on hosts other than Windows.

To Reproduce

On a MacOS or Windows machine

On a Windows machine

Expected behavior On Windows and MacOS, within a Linux Dev Container or on the host

Environment

VS Code: Version: 1.93.1 Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40 azd version 1.10.1 (commit 31409a33266fb4a5fdbb644bc83988e725d6c7c9)

weikanglim commented 5 days ago

Hi @cedricvidal our team will take a look at this soon. In the meantime, I tried accessing https://github.com/cedricvidal/azd-hook-interactive-python and got a 404. I think this usually means I may not have the right permissions to view it -- if this repro repository is okay to share, would you be able to check on your side that it's set to public access? Thanks!

cedricvidal commented 5 days ago

Hello Wei,

thanks for your quick response! My bad, the repo was private, I changed its visibility to public, you should be able to access it.

Let me know if you have any question.

Cedric

weikanglim commented 1 day ago

Hi @cedricvidal, thanks for updating the repro repository. I took a closer look, and it seems that azd hooks run isn't respecting the interactive flag. However, it does seem to work during the actual hook execution.

I modified the repro slightly to have a valid preprovision hook:

name: azd-test
hooks:
  preprovision:
    shell: sh
    run: ./test.sh
    interactive: true
    continueOnError: false

And verified azd provision does indeed prompt:

image

However, just as you have noticed, azd hooks run preprovision fails because stdin/stdout isn't attached:

image

I have updated the issue title based on these findings. cc: @wbreza