Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/build/resolveOpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {DeRefedOpenAPI} from './open-api/types';

// SENTRY_API_SCHEMA_SHA is used in the sentry-docs GHA workflow in getsentry/sentry-api-schema.
// DO NOT change variable name unless you change it in the sentry-docs GHA workflow in getsentry/sentry-api-schema.
const SENTRY_API_SCHEMA_SHA = 'fdf99d37c70f0f55704ec23c2e3f5893b8220577';
const SENTRY_API_SCHEMA_SHA = 'b7dd6d5bb8c9cb43c43513717617666b8cfb52ac';

Comment on lines +11 to 12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bug: The resolveOpenAPI function lacks an error check after a fetch call, causing an unhandled SyntaxError if the response is not valid JSON, crashing API documentation pages.
  • Description: The resolveOpenAPI function fetches an OpenAPI schema from a raw.githubusercontent.com URL. It does not validate the HTTP response status before attempting to parse the body as JSON with response.json(). If the fetch request fails (e.g., due to an invalid commit SHA, network error, or GitHub service issue), the server will likely return a non-200 response with an HTML body. Calling response.json() on this HTML will throw a SyntaxError. This unhandled exception will propagate up to the page rendering logic, causing a server-side crash for any user visiting an API documentation page.

  • Suggested fix: Before calling await response.json(), check if the response was successful using if (!response.ok). If the response is not ok, throw a descriptive error like new Error('Failed to fetch API schema') to prevent the JSON parsing error and provide clearer failure information.
    severity: 0.65, confidence: 0.95

Did we get this right? 👍 / 👎 to inform future reviews.

const activeEnv = process.env.GATSBY_ENV || process.env.NODE_ENV || 'development';

Expand Down
Loading