Skip to content

Comments

Gracefully catch unexpected html (non json) response from external services#6873

Open
alfonso-noriega wants to merge 1 commit intomainfrom
1325-error-unexpected-token-htmlh-is-not-valid-json
Open

Gracefully catch unexpected html (non json) response from external services#6873
alfonso-noriega wants to merge 1 commit intomainfrom
1325-error-unexpected-token-htmlh-is-not-valid-json

Conversation

@alfonso-noriega
Copy link
Contributor

@alfonso-noriega alfonso-noriega commented Feb 20, 2026

WHY are these changes introduced?

Issue #1325

Vault error

Observe error

JSON parsing errors in HTTP responses were causing unhandled exceptions and poor error messages when external services return malformed responses or are temporarily unavailable.

WHAT is this pull request doing?

Add proper error handling for JSON parsing failures in HTTP response processing across three modules:

  • Token exchange service: Wrap JSON parsing in try-catch and throw descriptive BugError when identity service returns invalid JSON
  • GitHub API client: Handle JSON parsing errors when fetching release information and provide clear error messaging
  • Admin authentication: Add error handling for malformed responses from the admin authentication service

All error messages inform users that the service may be temporarily unavailable and suggest retrying.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@alfonso-noriega alfonso-noriega force-pushed the 1325-error-unexpected-token-htmlh-is-not-valid-json branch 2 times, most recently from ccb9924 to 50808c2 Compare February 20, 2026 16:50
@alfonso-noriega alfonso-noriega force-pushed the 1325-error-unexpected-token-htmlh-is-not-valid-json branch from 50808c2 to 9d4ac4e Compare February 20, 2026 17:24
@github-actions
Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.89% 14560/18457
🟡 Branches 73.22% 7222/9863
🟡 Functions 79.09% 3704/4683
🟡 Lines 79.23% 13767/17375

Test suite run success

3777 tests passing in 1455 suites.

Report generated by 🧪jest coverage report action from 9d4ac4e

@alfonso-noriega alfonso-noriega marked this pull request as ready for review February 20, 2026 17:55
@alfonso-noriega alfonso-noriega requested a review from a team as a code owner February 20, 2026 17:55
@github-actions
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

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