Skip to content

fix(social): preserve non-JSON token endpoint errors - #1363

Open
oiahoon wants to merge 1 commit into
FoalTS:masterfrom
oiahoon:fix/token-error-response-body
Open

fix(social): preserve non-JSON token endpoint errors#1363
oiahoon wants to merge 1 commit into
FoalTS:masterfrom
oiahoon:fix/token-error-response-body

Conversation

@oiahoon

@oiahoon oiahoon commented Jul 15, 2026

Copy link
Copy Markdown

Problem

A non-2xx token endpoint response with an empty or non-JSON body is parsed with response.json() before its status is checked. This throws a JSON parsing error instead of a TokenError, losing the HTTP status and any plain-text response details.

Fixes #1297.

Solution

  • create TokenError instances from JSON, text, empty, or unreadable error responses
  • retain the HTTP status while preserving the existing one-argument constructor behavior
  • leave successful token response parsing unchanged
  • add direct and integration coverage for each error-body case

Testing

  • npm test --workspace=@foal/social with Node 22 (64 passing)
  • npm test --workspace=@foal/social with Node 24 (64 passing)
  • npx lerna run build
  • npm run lint
  • git diff --check

Checklist

  • I have read the contribution guidelines.
  • I have added or updated tests for any code changes.
  • I have updated documentation if needed, keeping it concise.

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.

AbstractProvider.getUserInfo throws an 'Unexpected end of JSON input' message in case of LinkedIn HTTP 429 error

1 participant