Skip to content

fix(sdk): return typed errors for malformed JSON responses#2911

Open
iroiro147 wants to merge 1 commit into
upstash:masterfrom
iroiro147:aovpr/context7-sdk-json-success-guard
Open

fix(sdk): return typed errors for malformed JSON responses#2911
iroiro147 wants to merge 1 commit into
upstash:masterfrom
iroiro147:aovpr/context7-sdk-json-success-guard

Conversation

@iroiro147

Copy link
Copy Markdown

Summary

  • convert empty or malformed successful JSON responses into a typed Context7Error
  • preserve valid JSON results and the existing network-retry boundary
  • add focused regression coverage and a patch changeset for @upstash/context7-sdk

Why

#2732 hardened the SDK's error-response path so response parsing could not leak a native SyntaxError. The successful application/json path still called res.json() without a guard, so an empty or malformed 200 response bypassed the SDK's typed error contract.

This keeps parsing after the fetch retry loop: malformed response bodies fail once and are not retried.

Follow-up to #2732 and #1964.

Tests

  • vitest run src/http/index.test.ts (7 tests)
  • SDK typecheck
  • SDK ESLint
  • SDK build
  • Prettier check
  • git diff --check

Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
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