Skip to content

Conversation

@getsantry
Copy link
Contributor

@getsantry getsantry bot commented Dec 12, 2025

No description provided.

@getsantry getsantry bot enabled auto-merge (squash) December 12, 2025 19:12
@vercel
Copy link

vercel bot commented Dec 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
develop-docs Ready Ready Preview Comment Dec 12, 2025 7:23pm
sentry-docs Ready Ready Preview Comment Dec 12, 2025 7:23pm

// 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 = 'd01587d742c372e25782eaa7e78e6df8286bfbc9';
const SENTRY_API_SCHEMA_SHA = 'dcb185faee28389a8eeeab4d09d1b9e0f7997963';

Copy link

Choose a reason for hiding this comment

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

Bug: The fetch call in resolveOpenAPI lacks error handling. It calls response.json() without first checking if the network request was successful via response.ok, which can cause crashes.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The resolveOpenAPI function fetches a JSON schema from GitHub using fetch. However, it does not check if the response was successful (e.g., response.ok) before attempting to parse the body as JSON with response.json(). If GitHub returns a non-2xx status code, such as a 404 or 500, response.json() will fail when trying to parse the resulting error page's HTML. This unhandled promise rejection will cause a Next.js server component to crash, resulting in a 500 error for the user, or cause the entire site build to fail during the mdx.ts execution.

💡 Suggested Fix

Before calling await response.json(), add a check to ensure the request was successful. For example: if (!response.ok) { throw new Error(Failed to fetch API schema: ${response.statusText}); }. This will provide a clear error message and prevent crashes from attempting to parse non-JSON responses.

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

Potential issue: The `resolveOpenAPI` function fetches a JSON schema from GitHub using
`fetch`. However, it does not check if the response was successful (e.g., `response.ok`)
before attempting to parse the body as JSON with `response.json()`. If GitHub returns a
non-2xx status code, such as a 404 or 500, `response.json()` will fail when trying to
parse the resulting error page's HTML. This unhandled promise rejection will cause a
Next.js server component to crash, resulting in a 500 error for the user, or cause the
entire site build to fail during the `mdx.ts` execution.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7465370

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