Skip to content

Handle invalid AWS profile gracefully instead of fatal exception#7393

Open
himani2411 wants to merge 3 commits into
aws:developfrom
himani2411:develop-profile
Open

Handle invalid AWS profile gracefully instead of fatal exception#7393
himani2411 wants to merge 3 commits into
aws:developfrom
himani2411:develop-profile

Conversation

@himani2411
Copy link
Copy Markdown
Contributor

Description of changes

When AWS_PROFILE is set to a non-existent profile, CLI commands using the @configure_aws_region() decorator (e.g. list-clusters, describe-cluster, list-official-images) raised an opaque "Unexpected fatal exception" message.

Catch botocore.exceptions.ProfileNotFound in _set_region(), configure_aws_region(), and configure_aws_region_from_config() and surface it as a BadRequestException with the actual error message.

This applies to all code paths: when --region is omitted (boto3.Session() fails in the decorator) and when --region is provided (boto3.Session() fails inside retrieve_supported_regions())

Tests

  • Local tests

References

  • Link to impacted open issues.
  • Link to related PRs in other packages (i.e. cookbook, node).
  • Link to documentation useful to understand the changes.

Checklist

  • Make sure you are pointing to the right branch.
  • If you're creating a patch for a branch other than develop add the branch name as prefix in the PR title (e.g. [release-3.6]).
  • Check all commits' messages are clear, describing what and why vs how.
  • Make sure to have added unit tests or integration tests to cover the new/modified code.
  • Check if documentation is impacted by this change.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When AWS_PROFILE is set to a non-existent profile, CLI commands using the
@configure_aws_region() decorator (e.g. list-clusters, describe-cluster,
list-official-images) raised an opaque "Unexpected fatal exception" message.

Catch botocore.exceptions.ProfileNotFound in _set_region(),
configure_aws_region(), and configure_aws_region_from_config() and surface
it as a BadRequestException with the actual error message.

This applies to all code paths: when --region is omitted (boto3.Session()
fails in the decorator) and when --region is provided (boto3.Session()
fails inside retrieve_supported_regions())
@himani2411 himani2411 requested review from a team as code owners May 12, 2026 22:14
@himani2411 himani2411 added skip-changelog-update Disables the check that enforces changelog updates in PRs 3.x labels May 12, 2026
@himani2411 himani2411 enabled auto-merge (rebase) May 18, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x skip-changelog-update Disables the check that enforces changelog updates in PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant