aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.51k stars 4.12k forks source link

When auto-prompt is on, aws codecommit credential-helper fails. #8370

Closed t-morissey closed 10 months ago

t-morissey commented 10 months ago

Describe the bug

aws codecommit credential-helper command fails when auto-prompt is on.

Expected Behavior

If auto-prompt is on, the command will successfully complete.

Current Behavior

The command fails with a warning Warning: Input is not a terminal (fd=0). and an error Unknown options: protocol=https.

Reproduction Steps

  1. Enable auto-prompt
  2. git config --global credential.helper '!aws codecommit credential-helper $@'
  3. git config --global credential.UseHttpPath true
  4. git clone https://git-codecommit..amazonaws.com/v1/repos/

My output:

$ export AWS_CLI_AUTO_PROMPT=on
$ git config --global credential.helper '!aws codecommit credential-helper $@'
$ git config --global credential.UseHttpPath true
$ git clone https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/xxxxxxx
Cloning into 'xxxxxxx'...
Warning: Input is not a terminal (fd=0).
warning: invalid credential line: > aws codecommit credential-helper get

Unknown options: protocol=https
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
Username for 'https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/xxxxxxx':

Possible Solution

I guess this error is caused by the temporary use of STDOUT to show prompt when using auto-prompt, which does not happen when on-partial, it might be enough to just mention that in the documentation.

Additional Information/Context

No response

CLI version used

aws-cli/2.13.27

Environment details (OS name and version, etc.)

Python/3.11.6 Darwin/22.6.0 exe/x86_64 prompt/off

tim-finnigan commented 10 months ago

Hi @t-morissey thanks for reaching out. We received another issue related to auto-prompt recently: https://github.com/aws/aws-cli/issues/8330. I think it's worth having further discussion there around how the current behavior or documentation could be improved.

The CLI documentation does note the following for on-partial mode:

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.

If you have any specific feedback on the wording there or in any part of the CLI User Guide, we recommend using the Provide feedback link at the bottom of the page to send feedback.

I think the codecommit credential-helper command is unique in that it is "not designed to be called directly from the AWS CLI." So maybe just that examples file could be updated to highlight the scenario you mentioned. (A PR to update the wording may be considered but I can't guarantee that.)

But since other commands may be affected, it may be better to add a section for this to the AWS CLI Troubleshooting Guide.

github-actions[bot] commented 10 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.