test: cover malformed error responses - #599
Merged
Merged
Conversation
The error handling in SeamHttpClient distinguishes standard Seam error bodies, which become SeamHttpApiError, from everything else, which falls through is_api_error_response to raise_for_status. Only the first half was covered: the suite never exercised a non-JSON body, malformed JSON, a JSON body without an error object, or an error object without string type and message fields. Cover all four against the recording server, which grows an optional content type override so it can serve malformed JSON. The fake cannot produce these responses. This closes the same gap just restored in the Ruby SDK, where the equivalent branches briefly lost their specs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011DzapiU8A9NMdyoTybL9xB
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.
Follow-up to #598. After it merged, I audited the deleted tests against what remains on
main: nothing was lost — both deletedtest/workspacesfiles covered generated route methods, and workspace creation stayed covered in the multi-workspace tests. But the audit surfaced a gap the suite has always had, which the Ruby SDK briefly lost in the sibling PR and is getting restored in seamapi/ruby#538 — so this closes it here too for parity.The gap
SeamHttpClient._handle_error_responsesplits error responses in two: standard Seam error bodies becomeSeamHttpApiError, and everything else falls throughis_api_error_responsetoraise_for_status. Only the first half was covered. The suite never exercised:text/plain)errorobjecterrorobject without stringtypeandmessagefieldsAll four now assert a plain
niquests.HTTPErrorwith the original status, driven by the recording server — the fake cannot produce these responses. The recording server grows an optional third tuple element to override the content type, which is what lets it serve malformed JSON.Tests only, no SDK changes.
Verification
black --check,pylint(10.00/10) clean.Generated by Claude Code