Skip to content
Closed
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 = '22b478f0984d0047b4f7e53b3c3bdb7a99bf418d';
const SENTRY_API_SCHEMA_SHA = '8fb68c98620c715cf4081fe036ec809a9f4e9a4c';
Copy link

Choose a reason for hiding this comment

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

Bug: The code processes an API schema response without validation. If the schema structure changes in this update, it could cause runtime errors due to unchecked property access.
Severity: HIGH | Confidence: Very low

🔍 Detailed Analysis

The function resolveOpenAPI fetches and parses an OpenAPI schema without validating its structure. The code assumes the existence of specific properties like data.tags and that each endpoint has a tags array with an x-sidebar-name property. This pull request updates the API schema version. If the new schema version introduces structural changes that don't align with these assumptions, it could lead to runtime errors during page rendering, frontmatter processing, or MDX processing, as there is no defensive error handling.

💡 Suggested Fix

Implement schema validation on the JSON response before processing it to ensure it conforms to the expected structure. Additionally, add defensive checks for properties like tags and x-sidebar-name to handle cases where they might be missing, preventing potential crashes.

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

Potential issue: The function `resolveOpenAPI` fetches and parses an OpenAPI schema
without validating its structure. The code assumes the existence of specific properties
like `data.tags` and that each endpoint has a `tags` array with an `x-sidebar-name`
property. This pull request updates the API schema version. If the new schema version
introduces structural changes that don't align with these assumptions, it could lead to
runtime errors during page rendering, frontmatter processing, or MDX processing, as
there is no defensive error handling.

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


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

Expand Down
Loading