aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.09k stars 4.01k forks source link

Error exit value doesn't quite match what `help return-codes` describe #8766

Open Farmbuyer opened 1 week ago

Farmbuyer commented 1 week ago

Describe the bug

According to aws help return-codes:

* "1" -- Limited to "s3" commands, at least one or more s3 transfers
  failed for the command executed.

[...]

* "253" -- The system environment or configuration was invalid. While
  the command provided may be syntactically valid, missing
  configuration or credentials prevented the command from running.

However,

$ cd ~/.aws
$ rm config credentials
$ aws configure get region
$ echo $?
1
$ 

[The same behavior occurs no matter what config key is being requested, including section-qualified names like default.region.]

Expected Behavior

I would have expected either an exit code of 253, or for the builtin documentation for return-code=1 to be better (since obviously this happens for more than just S3 transfer commands).

Current Behavior

This probably falls into "documentation bug" rather than "documentation is correct and CLI configuration parser is buggy". However, the description for doc bugs in the github issue-reporting form only mentioned User Guide and API docs, so dunno how you want to categorize this.

Reproduction Steps

Remove the config file (and optionally point AWS_CONFIG_FILE at a nonexistent file, as per #7714), then run any of the aws configure get commands. Compare the return code with that described in the builtin help.

Possible Solution

No response

Additional Information/Context

Obviously a low-priority problem. Dunno which you consider to be authoritative ("code to the doc spec" versus "docs describe what actually exists"), but somewhere there's a mismatch. :-)

CLI version used

aws-cli/2.17.0 Python/3.11.8 Windows/10 exe/AMD64

Environment details (OS name and version, etc.)

Windows 10 but the builtin docs are presumably the same everywhere

tim-finnigan commented 5 days ago

Thanks for reporting, I could reproduce this issue. (In my case I had to remove my config file though, where the region was set). Linking documentation on return codes: https://awscli.amazonaws.com/v2/documentation/api/latest/topic/return-codes.html

It says 1 is limited to s3 commands, but we received an exit value of 1 when aws configure get failed:

1 -- Limited to s3 commands, at least one or more s3 transfers failed
         for the command executed.

There was a big overhaul to improve consistency in https://github.com/aws/aws-cli/pull/4890 a few years ago but this must have been missed. I would probably expect 253CONFIGURATION_ERROR_RC here.