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 @@

// 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 = '4d727be1ea79676354f4242387b3645ac0e0dcf9';
const SENTRY_API_SCHEMA_SHA = '{"message":"API rate limit exceeded for 40.76.191.138. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}';

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.

Check failure on line 9 in src/build/resolveOpenAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

',' expected.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GitHub API error message committed as schema SHA

High Severity

SENTRY_API_SCHEMA_SHA was overwritten with a GitHub API rate limit error JSON string instead of a valid git commit SHA. This value is interpolated into a raw.githubusercontent.com URL on line 27 to fetch the OpenAPI schema, which will now fail for all non-local-development builds, completely breaking API documentation generation.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8ad285c. Configure here.


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

Comment on lines +9 to 12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: If SENTRY_API_SCHEMA_SHA contains an invalid value, the fetch call will throw an unhandled TypeError due to a malformed URL, crashing the build process.
Severity: HIGH

Suggested Fix

Wrap the fetch call in resolveOpenAPI within a try/catch block to handle potential TypeError exceptions from malformed URLs. Additionally, add a check for response.ok to handle non-2xx HTTP responses and prevent build failures.

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-L12

Potential issue: The `SENTRY_API_SCHEMA_SHA` environment variable, when it contains a
non-SHA value like a GitHub API rate-limit error, is interpolated directly into the URL
for a `fetch` call. This creates a malformed URL, causing `fetch` to throw a
`TypeError`. Because this call is not wrapped in a `try/catch` block and lacks a
`response.ok` check, the resulting unhandled promise rejection propagates up the call
stack from `resolveOpenAPI()` and crashes the entire documentation site's build process.

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

Expand Down
Loading