Repository navigation
Conversation
Rejected requests only read `code` from the response body. Services
that send just a stable identifier in `error`, such as the relayer's
403 `{"error":"NOT_ALLOWED"}`, left `RequestRejectedError.code` empty.
Promote lower- or upper-case snake_case `error` values to `code` for
non-400 responses, matching the TypeScript SDK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes DEFIQA-2402 for the Python SDK. TypeScript counterpart: Polymarket/ts-sdk#501.
RequestRejectedError.codewas only filled from acodefield in the response body. The relayer now answers 403 with{"error":"NOT_ALLOWED"}, and other services send lower-case identifiers such as{"error":"signer_does_not_match_account"}, socodecame back asNone.When there is no
codefield, the transport now useserroras the code if it is a lower- or upper-case snake_case identifier and the status is not 400. Free-text messages and 400 validation details are unchanged. This matches the TypeScript SDK's behavior.Testing
test_transport.pycase covering 403NOT_ALLOWED, 422 lower-case identifier, 403 free text, and 400 identifieruv run pytest tests/unit: all pass except two deposit-wallet tests that make live network calls and fail onmaintoouv run ruff check,uv run ruff format --check,uv run pyright🤖 Generated with Claude Code
Note
Low Risk
Narrow change to HTTP error parsing in the transport layer, with unit tests and no auth or data-path impact.
Overview
RequestRejectedError.codewas only populated from a JSONcodefield, so responses like relayer 403 with{"error":"NOT_ALLOWED"}or other services with snake_caseerrorvalues leftcodeasNone.The transport’s
_extract_response_error_codenow treatserroras the code when there is nocode, the status is not 400, anderrormatches a snake_case identifier (upper or lower). Human-readableerrorstrings and 400 validation bodies still do not setcode, aligning with the TypeScript SDK.Tests assert 400 keeps
codeNoneand add a parametrized case forNOT_ALLOWED, lower-case identifiers, free text, and 400 bodies.Reviewed by Cursor Bugbot for commit eee289d. Bugbot is set up for automated code reviews on this repo. Configure here.