twilio / twilio/twilio-ruby

[BUG] Lookup API dropped CGI escape of spaces in phone number values

Open Beginner friendly
#784 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Ruby
Stars
1.4k
Forks
472
Avg merge
1d 3h
Merged PRs (30d)
5

Description

Describe the bug

In the latest (7.10.4) release the phone number value for validation no longer does CGI escaping of spaces which results in an error when validating a phone number with a space in it. This looks to be a recurring regression that has been patched in the past: https://github.com/twilio/twilio-ruby/pull/468

Current:
https://github.com/twilio/twilio-ruby/blob/ceb021adacc73d483edd8b1aa9292a261fe26558/lib/twilio-ruby/rest/lookups/v1/phone_number.rb#L56

Previously:
https://github.com/twilio/twilio-ruby/blame/c84cb9b18e787e02bd66511103367bbb68a97a79/lib/twilio-ruby/rest/lookups/v1/phone_number.rb#L54

@uri = "/PhoneNumbers/#{CGI.escape(@solution[:phone_number]).gsub("+", "%20")}"
Code snippet

https://lookups.twilio.com/v1/PhoneNumbers/555 555 5555

Actual behavior

When given "555 555 5555" as a phone number value validation errors because of the spaces in the phone value now that the value is no longer CGI escaped.

Expected behavior

If given phone "555 555 5555" it should be possible to validate without error.

twilio-ruby version

7.10.3

Ruby version

3.3.2

Logs or error messages

bad URI(is not URI?): "https://lookups.twilio.com/v1/PhoneNumbers/555 555 5555"

Additional context

The value still containing spaces results in URI::InvalidURIError errors within Faraday's URI.parse() call when the URL looks like
https://lookups.twilio.com/v1/PhoneNumbers/555 555 5555

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/twilio-ruby/rest/lookups/v1/phone_number.rb around line 56 and compare it with the previous implementation linked in the issue. Reproduce the request using the phone number "555 555 5555" and verify that validation no longer raises URI::InvalidURIError when the URL is constructed.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.