fix: handle non-JSON error bodies in WaterCrawl exceptions#37536
Open
ifer47 wants to merge 2 commits into
Open
fix: handle non-JSON error bodies in WaterCrawl exceptions#37536ifer47 wants to merge 2 commits into
ifer47 wants to merge 2 commits into
Conversation
Jina credential validation delegates to the pooled HTTP client without an explicit timeout. A slow or hanging Jina endpoint can stall credential validation indefinitely. Add a bounded httpx.Timeout (10s read, 3s connect) consistent with other auth provider patterns, and update test assertions to verify the timeout is passed. Fixes langgenius#37524 Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
…s#37513) WaterCrawlBadRequestError.__init__ called response.json() unconditionally. When the server returns a non-JSON error body (e.g. HTML from a proxy/gateway), this leaked a JSONDecodeError to the caller instead of providing a meaningful error message. Wrap the JSON parsing in a try/except for (ValueError, json.JSONDecodeError) and fall back to response.text when the body is not valid JSON. If text is also empty, use a generic "Unknown error occurred" message. Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
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.
Summary
WaterCrawlBadRequestError.__init__calledresponse.json()unconditionally, which leaksJSONDecodeErrorwhen the server returns a non-JSON error body (e.g. HTML from a proxy/gateway)try/exceptfor(ValueError, json.JSONDecodeError)and fall back toresponse.textwhen the body is not valid JSONresponse.textis also empty, use a generic "Unknown error occurred" messageCloses #37513
Test plan
TestWaterCrawlExceptionsMagicMockresponses that raiseValueErroron.json()🤖 Generated with Claude Code Best