-
Notifications
You must be signed in to change notification settings - Fork 471
fix: Regional API domain processing #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements automatic edge mapping from region codes and deprecates the edge parameter in favor of region. When a region code (like 'ie1') is provided, the system now automatically maps it to the corresponding edge location (like 'dublin'). However, the implementation has several critical issues that need to be addressed.
Key Changes:
- Added
@@region_mappingshash to map region codes to edge locations - Removed
edgefromattr_accessorand added custom getter/setter with deprecation warnings - Modified initialization to automatically set edge based on region mapping
- Updated tests to validate region-to-edge mapping and deprecation warnings
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
lib/twilio-ruby/base/client_base.rb |
Adds region-to-edge mapping hash, implements automatic edge assignment from region, adds deprecation warnings for edge getter/setter, removes edge from attr_accessor |
spec/rest/client_spec.rb |
Updates test to reflect that global edge config is now ignored, adds test for region-to-edge mapping with 'ie1' → 'dublin', adds test for edge setter deprecation warning |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/twilio-ruby/base/client_base.rb
Outdated
| @password = password || Twilio.auth_token | ||
| @region = region || Twilio.region | ||
| @edge = Twilio.edge | ||
| @edge = !region.nil? ? @@region_mappings[region] : nil |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple issues with this edge initialization logic:
-
Ignores
Twilio.edgecompletely: The old code was@edge = Twilio.edge, but now it's completely ignored. This is a breaking change that should either be documented or handled with a deprecation warning. -
Doesn't handle the
Twilio.regionfallback: Whenregionparameter isnilbutTwilio.regionis set (line 27), the mapping won't work because the check uses the parameterregion, not@region. -
Silent failure for unmapped regions: Returns
nilfor invalid/unmapped regions without any warning.
Suggested fix:
@region = region || Twilio.region
@edge = if @region && @@region_mappings[@region]
@@region_mappings[@region]
elsif Twilio.edge
warn '[DEPRECATION] Setting edge via Twilio.edge is deprecated. Use Twilio.region instead.'
Twilio.edge
else
nil
end| @edge = !region.nil? ? @@region_mappings[region] : nil | |
| if @region && @@region_mappings[@region] | |
| @edge = @@region_mappings[@region] | |
| elsif Twilio.edge | |
| warn '[DEPRECATION] Setting edge via Twilio.edge is deprecated. Use Twilio.region instead.' | |
| @edge = Twilio.edge | |
| else | |
| warn "[WARN] Region '#{@region}' is not mapped to an edge. @edge set to nil." unless @region.nil? | |
| @edge = nil | |
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
lib/twilio-ruby/base/client_base.rb
Outdated
| @password = password || Twilio.auth_token | ||
| @region = region || Twilio.region | ||
| @edge = Twilio.edge | ||
| @edge = !region.nil? ? @@region_mappings[region] : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
tiwarishubham635
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!


Fixes
Changes:
Checklist
If you have questions, please file a support ticket, or create a GitHub Issue in this repository.