Skip to content
Open
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 = 'c23d6d909bba24a1c8c394378d3ff8229eb66202';

const activeEnv = process.env.GATSBY_ENV || process.env.NODE_ENV || 'development';
Comment on lines 12 to 13
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 doesn't handle non-200 HTTP responses from fetch before calling response.json(), which can cause a crash if the external API returns an error.
  • Description: The resolveOpenAPI function fetches an OpenAPI schema from a raw GitHub URL. It directly calls response.json() on the result without first checking if the HTTP request was successful (e.g., via response.ok). If the fetch fails for any reason, such as a 404 error or a temporary GitHub outage, the response will likely be an HTML error page. Attempting to parse this HTML as JSON will throw a SyntaxError, causing an unhandled exception. This will crash the documentation build process and also cause server-side rendering failures for API documentation pages, as the function is used in both critical paths.

  • Suggested fix: Before calling await response.json(), add a check for the response status. If !response.ok, throw an informative error to prevent the application from crashing due to an attempt to parse a non-JSON response. For example: if (!response.ok) { throw new Error(Failed to fetch OpenAPI schema: ${response.statusText}); }.
    severity: 0.7, confidence: 0.95

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


Expand Down
Loading