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 = 'b165d78cc294cdc11eb8c9f6b7935c1e9990ff7d';
const SENTRY_API_SCHEMA_SHA = '0259ad9aa394be67d7ca060db3b4dd914264a777';
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 accesses categoryMap[tag].apis without checking if tag exists. An API operation with a tag not defined in the top-level schema will cause a build crash.
Severity: HIGH

Suggested Fix

Add a defensive check before accessing categoryMap[tag]. You can use optional chaining (categoryMap[tag]?.apis.push(...)) or an explicit if (categoryMap[tag]) block to ensure the key exists before attempting to push to the apis array. This will prevent the build from crashing on malformed schema data.

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: In `resolveOpenAPI.ts`, the code populates a `categoryMap` object with
keys from the top-level `data.tags` array of the OpenAPI schema. Later, it iterates
through `apiData.tags` (a list of tag strings from individual API operations) and
directly accesses `categoryMap[tag].apis.push(...)`. If an API operation uses a tag that
was not defined in the top-level `tags` array, `categoryMap[tag]` will be `undefined`.
This will cause a `TypeError: Cannot read property 'apis' of undefined`, which will
crash the entire documentation build process.

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


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

Expand Down
Loading