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

Auto-prompt mode breaks non-interactive aws usage #8330

Open
joehorsnell opened this issue Nov 15, 2023 · 5 comments
Open

Auto-prompt mode breaks non-interactive aws usage #8330

joehorsnell opened this issue Nov 15, 2023 · 5 comments
Labels
auto-prompt-mode Issues related to CLI auto-prompt mode bug This issue is a bug. needs-review This issue or pull request needs review from a core team member. p3 This is a minor priority issue

Comments

@joehorsnell
Copy link

joehorsnell commented Nov 15, 2023

Describe the bug

Enabling the auto-prompt feature, eg using AWS_CLI_AUTO_PROMPT=on, breaks non-interactive use of aws, such as invoking from a script.

A couple of related issues, #5317 and #7862, have comments suggesting the use of on-partial, eg using AWS_CLI_AUTO_PROMPT=on-partial, but this is really a workaround.

The AWS CLI should check if it's being invoked interactively, eg checking for a tty, and conditionally disable auto-prompt mode, as you should only ever want that behaviour when running interactively.

Expected Behavior

aws should work correctly non-interactively (eg when invoked from a script) by disabling auto-prompt mode if it's on.

Current Behavior

aws displays the auto-prompt when invoked non-interactively, eg from a script, rather than running the desired command, breaking the script.

Reproduction Steps

Enable auto-prompt mode, using export AWS_CLI_AUTO_PROMPT=on and run any aws command from a script.

Possible Solution

As per description, check for a tty.

Additional Information/Context

No response

CLI version used

aws-cli/2.13.35 Python/3.11.6 Darwin/21.6.0 exe/x86_64

Environment details (OS name and version, etc.)

macOS Monterey 12.7

@joehorsnell joehorsnell added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 15, 2023
joehorsnell added a commit to joehorsnell/dotfiles that referenced this issue Nov 15, 2023
@joehorsnell
Copy link
Author

joehorsnell commented Nov 16, 2023

I had a quick poke around to see how easy this would be to fix and noticed that the initial implementation of auto-prompt in #5613 did have checks for TTY (here and here), but they were removed in #5635, which added the on-partial mode.

I'd say that's still a bug as, by definition, both auto-prompt modes (on and on-partial) are for interactive use, where a user is there to select an option if prompted. Non-interactive use should disable any auto-prompting mode, if enabled, as it can never work.

@tim-finnigan tim-finnigan self-assigned this Nov 28, 2023
@tim-finnigan
Copy link
Contributor

Hi @joehorsnell thanks for reaching out. Could you elaborate a bit more on why on-partial mode does not meet the requirements for your use case? Per the documentation that mode is intended for use cases involving pre-existing scripts:

on-partial uses partial auto-prompt mode. If a command is incomplete or cannot be run due to client-side validation errors, auto-prompt is used. This mode is particular useful if you have pre-existing scripts, runbooks, or you only want to be auto-prompted for commands you are unfamiliar with rather than prompted on every command.

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. auto-prompt-mode Issues related to CLI auto-prompt mode and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 28, 2023
@joehorsnell
Copy link
Author

Hi @tim-finnigan - thanks for getting back to me.

I do indeed have on-partial mode enabled now, after debugging the problem before opening the bug report.

In answer to your question, what if you wanted to always have auto-prompt for interactive use, but also be able to still use aws in scripts non-interactively? Or in other words, why have the on mode at all and only have on-partial mode, since the on mode currently is a bit of a foot gun?

I understand that this might not be deemed a priority to fix and this issue will probably end up getting automatically closed by the stale bot, but it is still a bug, so suggest you leave it labelled as such, even if it get closed as stale or "won't fix".

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 29, 2023
@tim-finnigan
Copy link
Contributor

Thanks for following up - I think we can keep tracking this for now, it would be good to get further input from the team. There are issues like #8370 where the current behavior could potentially be improved or better documented.

@tim-finnigan tim-finnigan removed their assignment Nov 29, 2023
@tim-finnigan tim-finnigan added bug This issue is a bug. p3 This is a minor priority issue needs-review This issue or pull request needs review from a core team member. labels Nov 29, 2023
@joehorsnell
Copy link
Author

Hi @tim-finnigan - yep, exactly - #8370 is, as you say, the same problem.

To recap, the basic issue is that both variants of the auto-prompt mode (on and on-partial) are only for interactive use and you never want auto-prompt, in any guise, enabled for script usage. The simplest solution I think is just to always check for a tty, to determine if aws is being invoked interactively, and fully disable auto-prompt if not.

I don't think it would be too difficult to fix, as per my comment above, the original implementation had much of the required code checks in it. I would potentially have a look at fixing it myself, if I knew that a PR would likely be accepted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-prompt-mode Issues related to CLI auto-prompt mode bug This issue is a bug. needs-review This issue or pull request needs review from a core team member. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants