Skip to content

Improve NoRegionError message with guidance on setting a region#3731

Open
viveka76 wants to merge 4 commits into
boto:developfrom
viveka76:improve-noregionerror-message
Open

Improve NoRegionError message with guidance on setting a region#3731
viveka76 wants to merge 4 commits into
boto:developfrom
viveka76:improve-noregionerror-message

Conversation

@viveka76

@viveka76 viveka76 commented Jun 21, 2026

Copy link
Copy Markdown

Description of changes: Expands the NoRegionError message to tell users
how to set a region (region_name argument, AWS_DEFAULT_REGION, or
~/.aws/config), and calls out the common mistake of putting region in
~/.aws/credentials.
Message text only — no change to resolution behavior, precedence, or the
exception type. Backwards compatible. Unit test and changelog entry included.
By submitting this pull request, I confirm that you can use, modify, copy,
and redistribute this contribution, under the terms of your choice.
This pr message is generated by AI tools, and reviewed by Vivek Shaw

@SamRemis

Copy link
Copy Markdown
Contributor

@viveka76 , thank you for the PR! I agree, this error message could be more helpful.

There are a few notes before we can merge:

  1. The AWS CLI v1 catches this exception and expands on it, so this would wind up with a confusing error message for CLIv1 users where we mention the SDK specific error message. The CLIv1 is scheduled to go into maintenance mode on July 15th of this year, so they will no longer receive these updates at that point. Waiting until this date to merge would probably be the easiest way to handle this.
  2. The error message is good, but there are a few edits I'd like to make. I'll suggest a change with those shortly.
  3. The updated test doesn't define ctx but references it, so it will fail when it runs. Since error messages like this one are intended to be helpful and user-facing as opposed to part of the API contract that can be coded against, we generally don't assert on the content of the message directly. I'd recommend just reverting the changes to the test file.
  4. The PR description appears to be generated using an LLM. Please see our CONTRIBUTING.md file for guidance on how to use tools to contribute to this repo. Please update the PR description to include the info outlined there.

Comment thread tests/unit/test_regions.py Outdated
Comment thread botocore/exceptions.py Outdated
viveka76 and others added 2 commits July 1, 2026 22:47
Correct error message

Co-authored-by: SamRemis <sjremis94@gmail.com>
unit tests not needed

Co-authored-by: SamRemis <sjremis94@gmail.com>
@viveka76
viveka76 requested a review from SamRemis July 1, 2026 17:23
@viveka76

viveka76 commented Jul 1, 2026

Copy link
Copy Markdown
Author

@SamRemis Thank you for your valuable suggestions, I have applied your suggestions and also added the AI use in commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants