Skip to content

fix(client): keep upper-case error identifiers as codes - #501

Open
kartojal wants to merge 1 commit into
mainfrom
fix/relayer-uppercase-error-codes
Open

kartojal wants to merge 1 commit into
mainfrom
fix/relayer-uppercase-error-codes

Conversation

@kartojal

@kartojal kartojal commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes DEFIQA-2402.

The relayer now answers 403 with {"error":"NOT_ALLOWED"}. When a non-400 JSON error has no code field, ServiceClient only promoted lower-case snake_case error values to code, so this one came back as code: undefined.

The fallback now also accepts upper-case snake_case identifiers and keeps them as sent. Mixed case and 400 responses are unchanged.

Testing

  • New ServiceClient test for a 403 {"error":"NOT_ALLOWED"} response
  • pnpm exec vitest run --project client packages/client/src/ServiceClient.test.ts
  • pnpm typecheck

🤖 Generated with Claude Code


Note

Low Risk
Localized change to JSON error code inference in the HTTP client, covered by a new unit test with no auth or data-handling impact.

Overview
Fixes RequestRejectedError.code staying undefined when backends (e.g. the relayer) return non-400 JSON like {"error":"NOT_ALLOWED"} without a separate code field.

ServiceClient now treats upper-case snake_case error / message values as fallback codes, alongside the existing lower-case rule. Explicit code fields, 400 responses (no identifier promotion), and mixed-case strings are unchanged.

Adds a 403 / NOT_ALLOWED regression test and a patch changeset for @polymarket/client.

Reviewed by Cursor Bugbot for commit 67e5d38. Bugbot is set up for automated code reviews on this repo. Configure here.

Non-400 JSON errors without a code field only promoted lower-case
snake_case `error` values to `code`. The relayer now answers 403 with
`{"error":"NOT_ALLOWED"}`, so the code was dropped. Accept upper-case
snake_case identifiers too and keep them as sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant