Skip to content

Conversation

@manisha1997
Copy link
Contributor

@manisha1997 manisha1997 commented Nov 26, 2025

Fixes

Changes:

  1. Added deprecation warning
  2. Mapping of region edge
Screenshot 2025-11-26 at 11 19 21 PM

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

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

Copy link

Copilot AI left a 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_mappings hash to map region codes to edge locations
  • Removed edge from attr_accessor and 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.

@password = password || Twilio.auth_token
@region = region || Twilio.region
@edge = Twilio.edge
@edge = !region.nil? ? @@region_mappings[region] : nil
Copy link

Copilot AI Nov 28, 2025

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:

  1. Ignores Twilio.edge completely: 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.

  2. Doesn't handle the Twilio.region fallback: When region parameter is nil but Twilio.region is set (line 27), the mapping won't work because the check uses the parameter region, not @region.

  3. Silent failure for unmapped regions: Returns nil for 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
Suggested change
@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

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@password = password || Twilio.auth_token
@region = region || Twilio.region
@edge = Twilio.edge
@edge = !region.nil? ? @@region_mappings[region] : nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@tiwarishubham635 tiwarishubham635 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@manisha1997 manisha1997 merged commit bd17551 into main Nov 28, 2025
27 of 28 checks passed
@manisha1997 manisha1997 deleted the regional-api-domain-processing branch November 28, 2025 10: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.

4 participants