Skip to content

fix(monitors): Prevent crash when cron detector queryObj is null - #123085

Draft
sentry[bot] wants to merge 2 commits into
masterfrom
seer/fix/monitors-cron-details-null-queryobj
Draft

fix(monitors): Prevent crash when cron detector queryObj is null#123085
sentry[bot] wants to merge 2 commits into
masterfrom
seer/fix/monitors-cron-details-null-queryobj

Conversation

@sentry

@sentry sentry Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: Cannot read properties of null (reading 'slug') occurring in CronDetectorDetails when dataSource.queryObj is null.

The root cause was that the frontend code assumed dataSource.queryObj would always be present, but the API can return a valid CronDetector where this property is null (e.g., for misconfigured or partially-created monitors).

The solution implements the following changes:

  1. CronDetectorDetails (static/app/views/detectors/components/details/cron/index.tsx):

    • Introduced an early return null guard when dataSource.queryObj is null, ensuring that subsequent code relying on queryObj is not executed.
    • Moved useState and useCallback hooks to before the early return to comply with React's Rules of Hooks.
    • Updated calls to useDocsPanel and useMonitorProcessingErrors to use optional chaining (?.) for dataSource.queryObj.slug.
    • Modified getLatestCronMonitorEnv to safely handle a null queryObj.
  2. useMonitorProcessingErrors (static/app/views/insights/crons/useMonitorProcessingErrors.tsx):

    • Widened the monitorSlug type to string | undefined.
    • Added an enabled: !!monitorSlug option to useApiQuery to prevent API calls when monitorSlug is undefined.
    • Ensured internal calls to deleteMonitorProcessingErrorByType provide a fallback empty string (monitorSlug ?? '') when monitorSlug is undefined.
  3. useDocsPanel (static/app/views/detectors/components/details/cron/index.tsx):

    • Widened the monitorSlug parameter type to string | undefined.
    • Passed monitorSlug ?? '' to MonitorQuickStartGuide to satisfy its monitorSlug: string prop type.

Fixes JAVASCRIPT-3BHN

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 28, 2026
@sentry sentry Bot changed the title fix(monitors): Safely handle null queryObj in CronDetectorDetails fix(monitors): Prevent crash when cron detector queryObj is null Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants