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 = 'b02b0fc72d6cd844ace73aa326582f921bd50bce';
const SENTRY_API_SCHEMA_SHA = '149c5eb7c15d8d6637011a32cccfcedc5893fd89';

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] without verifying the tag exists. An API tag not defined in the root data.tags will cause a build-time crash.
Severity: HIGH

Suggested Fix

Add a defensive check to ensure categoryMap[tag] is defined before attempting to access its apis property. For example: if (categoryMap[tag]) { categoryMap[tag].apis.push({ ... }); }. This prevents the build from crashing if an API uses a tag not declared at the root level.

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 code populates a `categoryMap` using tags from the root-level
`data.tags`. It then iterates through each API's `apiData.tags` and attempts to access
`categoryMap[tag].apis.push(...)`. If an API operation uses a tag that is not defined in
the root `data.tags`, `categoryMap[tag]` will be `undefined`, causing a "Cannot read
property 'apis' of undefined" runtime error. This will crash the documentation build
process. The OpenAPI specification does not require all operation tags to be defined at
the root level, making this a potential point of failure with schema updates.

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

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

Expand Down
Loading