Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Props = React.HTMLAttributes<HTMLDivElement> & {
emptyMessage?: string;
limit?: number | null;
openInNewTab?: boolean;
projectIds?: number[];
query?: string;
toggleConnected?: (params: {detector: Detector}) => void;
};
Expand Down Expand Up @@ -75,6 +76,7 @@ export default function ConnectedMonitorsList({
limit = DEFAULT_DETECTORS_PER_PAGE,
query,
openInNewTab,
projectIds,
...props
}: Props) {
const canEdit = Boolean(connectedDetectorIds && typeof toggleConnected === 'function');
Expand All @@ -92,6 +94,7 @@ export default function ConnectedMonitorsList({
cursor,
query,
includeIssueStreamDetectors: true,
projects: projectIds,
},
{enabled: detectorIds === null || detectorIds.length > 0}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {Automation} from 'sentry/types/workflowEngine/automations';
import type {Detector} from 'sentry/types/workflowEngine/detectors';
import {getApiQueryData, setApiQueryData, useQueryClient} from 'sentry/utils/queryClient';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import ConnectedMonitorsList from 'sentry/views/automations/components/connectedMonitorsList';
import {DetectorSearch} from 'sentry/views/detectors/components/detectorSearch';
import {makeDetectorListQueryKey} from 'sentry/views/detectors/hooks';
Expand Down Expand Up @@ -64,6 +65,7 @@ function AllMonitors({
setSearchQuery(query);
setCursor(undefined);
}, []);
const {selection} = usePageFilters();
Copy link

Choose a reason for hiding this comment

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

Bug: Toggling monitors in the filtered 'All Monitors' section leads to incorrect cache updates due to a query key mismatch in toggleConnected.
Severity: HIGH | Confidence: 1.00

🔍 Detailed Analysis

When a user toggles a monitor in the 'AllMonitors' section, the toggleConnected function attempts to update the cache. However, the makeDetectorListQueryKey call within toggleConnected does not include the projects parameter, while the 'AllMonitors' list itself creates its query key with the projects parameter. This mismatch results in different query keys, preventing the cache update from correctly reflecting the change in the displayed list. Consequently, the UI might not accurately show the connection or disconnection status of the monitor.

💡 Suggested Fix

Modify the toggleConnected function to pass the projects parameter to makeDetectorListQueryKey when updating the cache, ensuring consistency with the query key used for fetching the filtered list.

🤖 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/automations/components/editConnectedMonitors.tsx#L68

Potential issue: When a user toggles a monitor in the 'AllMonitors' section, the
`toggleConnected` function attempts to update the cache. However, the
`makeDetectorListQueryKey` call within `toggleConnected` does not include the `projects`
parameter, while the 'AllMonitors' list itself creates its query key with the `projects`
parameter. This mismatch results in different query keys, preventing the cache update
from correctly reflecting the change in the displayed list. Consequently, the UI might
not accurately show the connection or disconnection status of the monitor.

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

Reference_id: 2787239


return (
<PageFiltersContainer>
Expand All @@ -83,6 +85,7 @@ function AllMonitors({
cursor={cursor}
onCursor={setCursor}
query={searchQuery}
projectIds={selection.projects}
openInNewTab
/>
</Section>
Expand Down
Loading