Skip to content

fix: capturing parent exception JsonException#832

Merged
sbansla merged 1 commit into
mainfrom
change_exception_5may
May 5, 2026
Merged

fix: capturing parent exception JsonException#832
sbansla merged 1 commit into
mainfrom
change_exception_5may

Conversation

@sbansla
Copy link
Copy Markdown
Contributor

@sbansla sbansla commented May 5, 2026

  • Fix when API returns null for integer fields (e.g., "code": null) in error responses.

@sbansla sbansla requested a review from kridai May 5, 2026 15:04
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@sbansla sbansla requested a review from Copilot May 5, 2026 15:29
Copy link
Copy Markdown

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 hardens error-response deserialization in Twilio REST clients so that malformed/unexpected JSON (including cases like integer fields returned as null) doesn’t escape as an unhandled JSON parsing/serialization exception, and instead falls back to existing error handling.

Changes:

  • Broadened exception handling during RestException.FromJson(...) parsing from JsonReaderException to JsonException.
  • Broadened exception handling during RestApiStandardException.FromJson(...) parsing from JsonReaderException to JsonException.
  • Applied the same behavior consistently across the standard, no-auth, and orgs-token REST clients.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Twilio/Clients/TwilioRestClient.cs Catch JsonException during error payload parsing to prevent unhandled JSON exceptions and allow fallback behavior.
src/Twilio/Clients/NoAuth/TwilioNoAuthRestClient.cs Same broadened JSON exception handling for the no-auth client error parsing path.
src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs Same broadened JSON exception handling for the bearer-token orgs client error parsing path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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