Skip to content

Comments

Improved UserTokenClient and ConnectorClient status code error handling#202

Merged
rodrigobr-msft merged 7 commits intomainfrom
users/robrandao/client-error-handling
Oct 27, 2025
Merged

Improved UserTokenClient and ConnectorClient status code error handling#202
rodrigobr-msft merged 7 commits intomainfrom
users/robrandao/client-error-handling

Conversation

@rodrigobr-msft
Copy link
Contributor

@rodrigobr-msft rodrigobr-msft commented Oct 23, 2025

This pull request updates the error handling and logging conventions in the connector and user token client modules to improve consistency and reliability when interacting with HTTP endpoints. The main changes involve refining status code checks for HTTP responses and switching logging statements from f-strings to parameterized logging for better performance and clarity.

Error Handling Improvements:

  • Updated HTTP response status code checks throughout connector_client.py and user_token_client.py to use more precise ranges or explicit status lists (e.g., changed from >= 400 to >= 300 or [200, 201, 202]), ensuring errors are caught more accurately and handling is consistent across all client methods. [1] [2] [3] [4] [5]

Logging Consistency and Performance:

  • Replaced all f-string formatted log messages with parameterized logging (e.g., "Error: %s", error_val) to improve logging performance and avoid unnecessary string interpolation when logging is disabled. This change applies to both info and error log statements in both client modules. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Response Handling Adjustments:

  • Improved handling for specific HTTP status codes (e.g., 404 responses now return empty TokenResponse objects instead of raising errors), making the client more robust to expected error scenarios. [1] [2]

Code Consistency:

Copilot AI review requested due to automatic review settings October 23, 2025 16:45
Copy link
Contributor

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 pull request standardizes error handling and logging practices across the UserTokenClient and ConnectorClient modules. The changes improve consistency in HTTP response validation and adopt parameterized logging for better performance.

  • Refined HTTP status code checks from >= 400 to >= 300 or explicit status lists for more accurate error detection
  • Converted f-string logging to parameterized logging to improve performance when logging is disabled
  • Enhanced 404 response handling to return empty TokenResponse objects instead of raising errors

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
user_token_client.py Updated status code checks from >= 400 to >= 300, converted all logging to parameterized format, and improved 404 handling to return empty TokenResponse objects
connector_client.py Changed status code validation to use explicit success lists ([200, 201, 202]) for write operations and >= 300 for read operations, converted logging to parameterized format

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rodrigobr-msft rodrigobr-msft linked an issue Oct 23, 2025 that may be closed by this pull request
@rodrigobr-msft rodrigobr-msft marked this pull request as ready for review October 23, 2025 20:21
@rodrigobr-msft rodrigobr-msft requested a review from a team as a code owner October 23, 2025 20:21
Copilot AI review requested due to automatic review settings October 23, 2025 20:21
Copy link
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 27, 2025 15:34
Copy link
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 21 comments.


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

@rodrigobr-msft rodrigobr-msft merged commit 9964b24 into main Oct 27, 2025
9 of 10 checks passed
@rodrigobr-msft rodrigobr-msft deleted the users/robrandao/client-error-handling branch October 27, 2025 19:33
Copilot AI mentioned this pull request Dec 2, 2025
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.

Improve error handling for ConnectorClient and UserTokenClient

2 participants