-
Notifications
You must be signed in to change notification settings - Fork 6
Fix JsonDecodeError to include server response content in error message #553
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
Conversation
Deploying infrahub-sdk-python with
|
| Latest commit: |
7858a62
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://de988df4.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://copilot-fix-473.infrahub-sdk-python.pages.dev |
Co-authored-by: BeArchiTek <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #553 +/- ##
==========================================
+ Coverage 75.59% 75.69% +0.09%
==========================================
Files 100 100
Lines 8892 8894 +2
Branches 1750 1751 +1
==========================================
+ Hits 6722 6732 +10
+ Misses 1688 1680 -8
Partials 482 482
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @copilot (not you @BeArchiTek 😆)
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
|
@copilot add the changelog file with the issue reference |
Co-authored-by: BeArchiTek <[email protected]>
Changes Made:
Fixed JsonDecodeError in
infrahub_sdk/exceptions.py: Modified the__init__method to append server response content to the default error message when available. This provides better debugging information when servers return non-JSON error responses.Added comprehensive tests in
tests/unit/sdk/test_utils.py: Added 4 new test cases to verify:decode_jsonworks correctly with valid JSONdecode_jsonincludes server content in error messages when availabledecode_jsonhandles empty content gracefullyAdded changelog entry: Created
changelog/473.fixed.mddocumenting the fix.The Fix:
The issue was that when servers return error responses that aren't JSON formatted (like HTML error pages or plain text error messages), users only saw a generic message like "Unable to decode response as JSON data from {url}" without the actual server error. Now they see the actual error content, making debugging much easier.
Before:
Unable to decode response as JSON data from https://example.com/graphqlAfter:
Unable to decode response as JSON data from https://example.com/graphql. Server response: Internal Server Error: Database connection failedThis fix is minimal and backward-compatible - it only affects the default error message generation when no custom message is provided.
Fixes #473.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.