Skip to content

chore: Preview for removing encoding from Phone NUmber format #871

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public Message create(final TwilioRestClient client) {
"{" + "AccountSid" + "}",
this.pathAccountSid.toString()
);
path = path.replace("{" + "To" + "}", this.to.encode("utf-8"));
path = path.replace("{" + "To" + "}", this.to.toString());

Request request = new Request(
HttpMethod.POST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public ValidationRequest create(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.phoneNumber.encode("utf-8")
this.phoneNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public Local create(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.phoneNumber.encode("utf-8")
this.phoneNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public Mobile create(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.phoneNumber.encode("utf-8")
this.phoneNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public TollFree create(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.phoneNumber.encode("utf-8")
this.phoneNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public PortingPortability fetch(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.pathPhoneNumber.encode("utf-8")
this.pathPhoneNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public AuthorizationDocument create(final TwilioRestClient client) {
path =
path.replace(
"{" + "ContactPhoneNumber" + "}",
this.contactPhoneNumber.encode("utf-8")
this.contactPhoneNumber.toString()
);
path =
path.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ public HostedNumberOrder create(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.phoneNumber.encode("utf-8")
this.phoneNumber.toString()
);
path =
path.replace(
"{" + "ContactPhoneNumber" + "}",
this.contactPhoneNumber.encode("utf-8")
this.contactPhoneNumber.toString()
);
path =
path.replace("{" + "AddressSid" + "}", this.addressSid.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public HostedNumberOrder create(final TwilioRestClient client) {
path =
path.replace(
"{" + "PhoneNumber" + "}",
this.phoneNumber.encode("utf-8")
this.phoneNumber.toString()
);
path =
path.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public NumberFetcher(final com.twilio.type.PhoneNumber pathNumber) {
public Number fetch(final TwilioRestClient client) {
String path = "/v1/Voice/Numbers/{Number}";

path =
path.replace("{" + "Number" + "}", this.pathNumber.encode("utf-8"));
path = path.replace("{" + "Number" + "}", this.pathNumber.toString());

Request request = new Request(
HttpMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Number fetch(final TwilioRestClient client) {
path =
path.replace(
"{" + "DestinationNumber" + "}",
this.pathDestinationNumber.encode("utf-8")
this.pathDestinationNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Number fetch(final TwilioRestClient client) {
path =
path.replace(
"{" + "DestinationNumber" + "}",
this.pathDestinationNumber.encode("utf-8")
this.pathDestinationNumber.toString()
);

Request request = new Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public Engagement create(final TwilioRestClient client) {
String path = "/v1/Flows/{FlowSid}/Engagements";

path = path.replace("{" + "FlowSid" + "}", this.pathFlowSid.toString());
path = path.replace("{" + "To" + "}", this.to.encode("utf-8"));
path = path.replace("{" + "From" + "}", this.from.encode("utf-8"));
path = path.replace("{" + "To" + "}", this.to.toString());
path = path.replace("{" + "From" + "}", this.from.toString());

Request request = new Request(
HttpMethod.POST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public Execution create(final TwilioRestClient client) {
String path = "/v1/Flows/{FlowSid}/Executions";

path = path.replace("{" + "FlowSid" + "}", this.pathFlowSid.toString());
path = path.replace("{" + "To" + "}", this.to.encode("utf-8"));
path = path.replace("{" + "From" + "}", this.from.encode("utf-8"));
path = path.replace("{" + "To" + "}", this.to.toString());
path = path.replace("{" + "From" + "}", this.from.toString());

Request request = new Request(
HttpMethod.POST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public Execution create(final TwilioRestClient client) {
String path = "/v2/Flows/{FlowSid}/Executions";

path = path.replace("{" + "FlowSid" + "}", this.pathFlowSid.toString());
path = path.replace("{" + "To" + "}", this.to.encode("utf-8"));
path = path.replace("{" + "From" + "}", this.from.encode("utf-8"));
path = path.replace("{" + "To" + "}", this.to.toString());
path = path.replace("{" + "From" + "}", this.from.toString());
Comment on lines +80 to +81
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

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

Phone numbers in URL paths should be properly encoded to handle special characters like '+' and spaces. Using toString() instead of encode("utf-8") may cause URL parsing errors for international phone numbers.

Suggested change
path = path.replace("{" + "To" + "}", this.to.toString());
path = path.replace("{" + "From" + "}", this.from.toString());
path = path.replace("{" + "To" + "}", URLEncoder.encode(this.to.toString(), "UTF-8"));
path = path.replace("{" + "From" + "}", URLEncoder.encode(this.from.toString(), "UTF-8"));

Copilot uses AI. Check for mistakes.

Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

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

Phone numbers in URL paths should be properly encoded to handle special characters like '+' and spaces. Using toString() instead of encode("utf-8") may cause URL parsing errors for international phone numbers.

Copilot uses AI. Check for mistakes.


Request request = new Request(
HttpMethod.POST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public ComplianceTollfreeInquiries create(final TwilioRestClient client) {
path =
path.replace(
"{" + "TollfreePhoneNumber" + "}",
this.tollfreePhoneNumber.encode("utf-8")
this.tollfreePhoneNumber.toString()
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

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

Removing UTF-8 encoding from phone numbers in URL paths may cause issues with special characters or international phone numbers. Phone numbers containing special characters like '+' or spaces should be properly URL-encoded when used in path parameters to prevent URL parsing errors.

Copilot uses AI. Check for mistakes.

);
path =
path.replace(
Expand Down