Skip to content

feat(investigations): add favorite and duplicate endpoints - #121683

Open
wedamija wants to merge 8 commits into
investigations/05-collection-apifrom
danf/investigations-favorite-duplicate
Open

feat(investigations): add favorite and duplicate endpoints#121683
wedamija wants to merge 8 commits into
investigations/05-collection-apifrom
danf/investigations-favorite-duplicate

Conversation

@wedamija

Copy link
Copy Markdown
Member

Add apis for favouriting and duplicating investigations

Split out from #121405

arslnb and others added 8 commits August 10, 2026 13:09
@wedamija
wedamija requested a review from arslnb August 10, 2026 23:00
@wedamija
wedamija requested a review from a team as a code owner August 10, 2026 23:00
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 10, 2026
Comment on lines +31 to +41
duplicate = duplicate_investigation(investigation=investigation, user_id=viewer_id)
return Response(
serialize(
duplicate,
request.user,
InvestigationDetailsSerializer(
accessible_project_ids=accessible_project_ids(self, request, organization)
),
),
status=status.HTTP_201_CREATED,
)

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.

Bug: The endpoint allows duplicating archived investigations, bypassing the intended read-only restriction that is enforced by other write operations.
Severity: MEDIUM

Suggested Fix

In the duplicate_investigation service function, add a check to ensure the source investigation's status is ACTIVE. If it is not, raise an InvestigationValidationError with the message "Archived investigations are read-only.", consistent with other write operations.

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/sentry/investigations/endpoints/organization_investigations_duplicate.py#L27-L41

Potential issue: The `duplicate_investigation` endpoint and its underlying service
function do not check if an investigation is archived before proceeding with
duplication. This is inconsistent with all other write operations on investigations
(e.g., `create_block`, `update_block`), which explicitly check for an `ACTIVE` status
and raise an error for archived ones. This allows users to bypass the intended read-only
contract for archived investigations by creating a new, active copy from an archived
source.

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

@wedamija
wedamija force-pushed the investigations/05-collection-api branch from 25e5b33 to f0e5d4a Compare August 10, 2026 23:12
@wedamija
wedamija force-pushed the danf/investigations-favorite-duplicate branch from 76f02bd to b79c8de Compare August 10, 2026 23:13
@arslnb
arslnb force-pushed the investigations/05-collection-api branch from bdb196b to 3ba799b Compare August 11, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants