aws / aws/aws-cli

Better error handling for s3 configuration blocks

Open
#9,469 1 comment 6 reactions 0 assignees View on GitHub
bug configuration p2
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the feature

Normally when you have an AWS configuration file error, you get a specific error message that points you in the right direction.

For example, normally bad AWS config file:

```
[default]
region = us-west-2

sjlkdfjlksdfjkljlkf
```

This results in expected error message, such as:

```
❯ aws sts get-caller-identity

Unable to parse config file: /home/gardnen/.aws/config
```

However, if you have a bad[ S3 configuration block ](https://awscli.amazonaws.com/v2/documentation/api/latest/topic/s3-config.html):

```
[default]
region=us-west-2
s3=
endpoint_url=http://localhost:1234/
```

You instead get the following:

```
❯ aws sts get-caller-identity

'str' object has no attribute 'get'
```

This is very confusing as a user, because there is no reference to the fact that there's an issue with the config file, and I'm not running any commands which would have to use s3. The same error handling for normal config file parsing should also apply to special blocks like s3 configuration.

It might be a bit of a stretch, but getting specific error messages about which line in the config file is generating the syntax error would be great.

### Use Case

I was trying to deploy some CDK, and kept getting nested errors where `'str' object has no attribute 'get'` was buried in giant error blocks. It took quite a bit of chasing to figure out the issue was in the configuration file.

### Proposed Solution

_No response_

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CLI version used

aws-cli/2.23.11 Python/3.9.21 Linux/6.1.132-147.221.amzn2023.x86_64 source/x86_64.amzn.2023

### Environment details (OS name and version, etc.)

AL2023

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.