Skip to content

Conversation

@jona62
Copy link
Contributor

@jona62 jona62 commented Oct 1, 2025

Fix validation exception which occurs if the default aws region mismatches with the user's region_name

Description of changes:
Fixed a validation exception that occurred when the default AWS region mismatched with the user's provided region_name. The issue was that region validation was happening after the boto3 session was created, which could cause conflicts.

Key fixes:

  1. Moved region validation before session creation - This prevents validation errors from occurring after the session is already established
  2. Made session parameter optional - Changed _validate_and_resolve_region to accept Optional[boto3.Session] instead of requiring a session
  3. Simplified validation logic - Streamlined the region conflict detection to be more robust

Fixes this error

ValueError: Region mismatch: provided region_name 'us-west-2' does not match boto3_session region 'us-east-1'. Please ensure both parameters specify the same region or omit the region_name parameter to use the session's region.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@5d5271d). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #102   +/-   ##
=======================================
  Coverage        ?   89.46%           
=======================================
  Files           ?       23           
  Lines           ?     2306           
  Branches        ?      331           
=======================================
  Hits            ?     2063           
  Misses          ?      139           
  Partials        ?      104           
Flag Coverage Δ
unittests 89.46% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jona62 jona62 force-pushed the chore/region_conflict_validation branch from b7636c9 to 1c696bb Compare October 1, 2025 16:11
@jona62 jona62 merged commit 207e3e0 into aws:main Oct 1, 2025
16 of 17 checks passed
@jona62 jona62 deleted the chore/region_conflict_validation branch October 1, 2025 16:17
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.

3 participants