Simplify error handling and move response checks to a response_handler module#1977
Merged
Simplify error handling and move response checks to a response_handler module#1977
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes HTTP response validation by moving Overkiz API error-to-exception mapping out of OverkizClient into a dedicated response_handler module, and expands test coverage with additional cloud error fixtures.
Changes:
- Added
pyoverkiz.response_handler.check_responsewith rule-based dispatch for mapping API error payloads to specific exceptions. - Updated
OverkizClientrequest helpers to call the sharedcheck_responsefunction instead of a class staticmethod. - Extended
tests/test_client.pyand added multiple new cloud exception fixtures to validate additional error mappings and fallbacks.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyoverkiz/client.py |
Replaces internal response checking with calls to the new shared check_response function (and removes the previous staticmethod). |
pyoverkiz/response_handler.py |
Introduces centralized response checking and exception dispatch logic. |
tests/test_client.py |
Updates tests to call the shared response handler and adds new exception cases. |
tests/fixtures/exceptions/cloud/exec-queue-full.json |
New fixture to validate EXEC_QUEUE_FULL → ExecutionQueueFullException. |
tests/fixtures/exceptions/cloud/invalid-event-listener-id.json |
New fixture to validate invalid event listener ID mapping. |
tests/fixtures/exceptions/cloud/invalid-token.json |
New fixture to validate invalid token mapping. |
tests/fixtures/exceptions/cloud/missing-api-key.json |
New fixture to validate missing API key mapping. |
tests/fixtures/exceptions/cloud/no-such-command.json |
New fixture to validate unsupported operation / invalid command mapping. |
tests/fixtures/exceptions/cloud/no-such-resource.json |
New fixture to validate invalid API call / no-such-resource mapping. |
tests/fixtures/exceptions/cloud/not-such-token.json |
New fixture to validate “not such token” mapping. |
tests/fixtures/exceptions/cloud/session-and-bearer.json |
New fixture to validate session+bearing token conflict mapping. |
tests/fixtures/exceptions/cloud/too-many-attempts-banned.json |
New fixture to validate temporary ban mapping. |
tests/fixtures/exceptions/cloud/unknown-auth-error.json |
New fixture to validate authentication error fallback behavior. |
tests/fixtures/exceptions/cloud/unknown-resource-access-denied.json |
New fixture to validate resource access denied fallback behavior. |
tests/fixtures/exceptions/cloud/unknown-user-account.json |
New fixture to validate unknown user mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
pyoverkiz.response_handler.check_response