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 @@ -13,8 +13,8 @@ import useOrganization from 'sentry/utils/useOrganization';
import {useUpdateDetector} from 'sentry/views/detectors/hooks';
import {useDeleteDetectorMutation} from 'sentry/views/detectors/hooks/useDeleteDetectorMutation';
import {
makeMonitorBasePathname,
makeMonitorDetailsPathname,
makeMonitorTypePathname,
} from 'sentry/views/detectors/pathnames';
import {detectorTypeIsUserCreateable} from 'sentry/views/detectors/utils/detectorTypeConfig';
import {useCanEditDetector} from 'sentry/views/detectors/utils/useCanEditDetector';
Expand Down Expand Up @@ -106,10 +106,10 @@ export function DeleteDetectorAction({detector}: {detector: Detector}) {
priority: 'danger',
onConfirm: async () => {
await deleteDetector(detector.id);
navigate(makeMonitorBasePathname(organization.slug));
navigate(makeMonitorTypePathname(organization.slug, detector.type));
Copy link

Choose a reason for hiding this comment

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

Bug: The makeMonitorTypePathname function is imported and called in actions.tsx but is not defined, leading to build or runtime errors.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

The makeMonitorTypePathname function is imported in static/app/views/detectors/components/details/common/actions.tsx but is not defined in static/app/views/detectors/pathnames.tsx or anywhere else in the codebase. This function is actively called at line 104 within the DeleteDetectorAction component. This will lead to a build-time failure due to a TypeScript/module resolution error or a runtime error when the DeleteDetectorAction component attempts to execute, preventing users from deleting detectors. The PR appears to be incomplete, as it introduces the usage of this function without defining it.

💡 Suggested Fix

Define the makeMonitorTypePathname function in static/app/views/detectors/pathnames.tsx to correctly map detector types to their corresponding list pages.

🤖 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/components/details/common/actions.tsx#L104

Potential issue: The `makeMonitorTypePathname` function is imported in
`static/app/views/detectors/components/details/common/actions.tsx` but is not defined in
`static/app/views/detectors/pathnames.tsx` or anywhere else in the codebase. This
function is actively called at line 104 within the `DeleteDetectorAction` component.
This will lead to a build-time failure due to a TypeScript/module resolution error or a
runtime error when the `DeleteDetectorAction` component attempts to execute, preventing
users from deleting detectors. The PR appears to be incomplete, as it introduces the
usage of this function without defining it.

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

Reference_id: 2785176

Copy link
Member Author

Choose a reason for hiding this comment

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

part of a diff PR

},
});
}, [deleteDetector, detector.id, navigate, organization.slug]);
}, [deleteDetector, detector.id, detector.type, navigate, organization.slug]);

const canEdit = useCanEditDetector({
detectorType: detector.type,
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/detectors/edit.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ describe('DetectorEdit', () => {
expect.anything()
);

// Redirect to the monitors list
// Redirect to the detector type-specific list page (metrics for MetricDetectorFixture)
expect(router.location.pathname).toBe(
`/organizations/${organization.slug}/monitors/`
`/organizations/${organization.slug}/monitors/metrics/`
);
});

Expand Down
Loading