Skip to content

fix(detectors): Safely access queryObj for cron monitors#119444

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/javascript-39qg-queryobj-null
Open

fix(detectors): Safely access queryObj for cron monitors#119444
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/javascript-39qg-queryobj-null

Conversation

@sentry

@sentry sentry Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: Cannot read properties of null (reading 'config') that occurs when detector.dataSources[0].queryObj is null for certain cron detectors.

The root cause was identified as queryObj being null at runtime for some cron detectors, despite the TypeScript type indicating it as non-null. The UI components were attempting to access properties like .config, .id, or .environments directly on a potentially null queryObj, leading to crashes.

This fix implements optional chaining (?.) and null checks in the following locations:

  • static/app/views/detectors/components/detectorLink.tsx: In CronDetectorDetails, config is now accessed safely, and the component returns null if config is undefined.
  • static/app/views/detectors/list/cron.tsx: In VisualizationCell, cronId and cronEnvironments are now safely extracted using optional chaining. The useMonitorStats hook is updated to handle a potentially null cronId.
  • static/app/views/detectors/list/cron.tsx: The environment column rendering now safely accesses environments using optional chaining, preventing crashes when queryObj is null.

These changes ensure the UI gracefully handles cases where queryObj is absent, preventing TypeErrors and improving stability.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes JAVASCRIPT-39QG

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@sentry sentry Bot requested a review from a team as a code owner July 10, 2026 22:38
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c6ddf6d. Configure here.

<SimpleTable.RowCell data-column-name="environment-label" alignSelf="start">
<Stack gap="sm" width="100%">
{detector.dataSources[0].queryObj.environments.map(environment => {
{detector.dataSources[0]?.queryObj?.environments.map(environment => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unsafe map on environments

High Severity

When queryObj is null, optional chaining yields undefined for environments, but .map is still invoked on that value. That throws the same class of runtime error this PR targets, so the environment column can still crash for cron detectors without a queryObj.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c6ddf6d. Configure here.

<SimpleTable.RowCell data-column-name="environment-label" alignSelf="start">
<Stack gap="sm" width="100%">
{detector.dataSources[0].queryObj.environments.map(environment => {
{detector.dataSources[0]?.queryObj?.environments.map(environment => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bug: Incomplete optional chaining on environments will cause a crash when queryObj is null. The .map() function will be called on an undefined value, throwing a TypeError.
Severity: HIGH

Suggested Fix

Add optional chaining before the .map() call to safely handle cases where environments is undefined. The line should be changed to {detector.dataSources[0]?.queryObj?.environments?.map(environment => { ... });}.

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: static/app/views/detectors/list/cron.tsx#L112

Potential issue: In the environment column renderer, the code accesses
`detector.dataSources[0]?.queryObj?.environments.map(...)`. While optional chaining is
used for `queryObj`, it is not used before the `.map()` call. The pull request's context
confirms that `queryObj` can be `null` at runtime. In such cases,
`detector.dataSources[0]?.queryObj?.environments` evaluates to `undefined`. Attempting
to call `.map()` on `undefined` will result in a `TypeError: Cannot read properties of
undefined (reading 'map')`, causing a crash in the UI component when rendering the
environment column for a detector with a null `queryObj`.

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

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