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 @@ -6,7 +6,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 = '4e1fa24c45cd047a0e1ccbea41faa1a706026be8';
const SENTRY_API_SCHEMA_SHA = '4c69fc3e332668b6480c78a9a7cdf0c417ddd317';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The resolveOpenAPI function lacks error handling for its fetch call to GitHub, which can lead to unhandled promise rejections and crash the build process.
Severity: HIGH

Suggested Fix

Wrap the fetch call and the response.json() invocation in a try-catch block. Additionally, check the response.ok property to ensure the HTTP request was successful before attempting to parse the body as JSON. If an error occurs, log it and handle it gracefully to prevent the application from crashing.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/build/resolveOpenAPI.ts#L9

Potential issue: The `resolveOpenAPI` function fetches an OpenAPI schema from GitHub
without handling potential network errors or non-200 HTTP responses. If the fetch fails
due to a network timeout, a GitHub service issue (e.g., 503 error), or another non-200
response, the subsequent call to `response.json()` will throw an unhandled promise
rejection. Because this function is called during the static build process via
`generateStaticParams`, such a failure will crash the entire build. It can also cause
runtime failures when accessing API pages.

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


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

Expand Down
Loading