Improve NoRegionError message with guidance on setting a region#3731
Open
viveka76 wants to merge 2 commits into
Open
Improve NoRegionError message with guidance on setting a region#3731viveka76 wants to merge 2 commits into
viveka76 wants to merge 2 commits into
Conversation
1 task
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:
|
SamRemis
requested changes
Jun 22, 2026
Comment on lines
+215
to
+217
| message = str(ctx.exception) | ||
| self.assertIn('You must specify a region', message) | ||
| self.assertIn('AWS_DEFAULT_REGION', message) |
Contributor
There was a problem hiding this comment.
Suggested change
| message = str(ctx.exception) | |
| self.assertIn('You must specify a region', message) | |
| self.assertIn('AWS_DEFAULT_REGION', message) |
Comment on lines
+247
to
+250
| 'You must specify a region. Set it via the region_name argument ' | ||
| 'to the client/Session, the AWS_DEFAULT_REGION environment ' | ||
| 'variable, or "region" in ~/.aws/config (note: region goes in ' | ||
| '~/.aws/config, not ~/.aws/credentials).' |
Contributor
There was a problem hiding this comment.
Suggested change
| 'You must specify a region. Set it via the region_name argument ' | |
| 'to the client/Session, the AWS_DEFAULT_REGION environment ' | |
| 'variable, or "region" in ~/.aws/config (note: region goes in ' | |
| '~/.aws/config, not ~/.aws/credentials).' | |
| 'You must specify a region. This can be done by passing the region_name ' | |
| 'argument to the client or session, using the AWS_DEFAULT_REGION ' | |
| 'environment variable, or setting "region" in the aws config file.' |
The reasoning behind these suggested edits:
regioncan be set in the credentials file and it will be respected by botocore- the filepath for the config file is not hard-coded and can be specified using the
AWS_CONFIG_FILEenvironment variable (same withAWS_SHARED_CREDENTIALS_FILEfor the credentials file) - While we could still include a reference to the credentials file, that would be a lot of detail for an error message. Most of the common cases would be covered with this update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes: Expands the
NoRegionErrormessage to tell usershow 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.