Repository navigation
fix(findings): offer no Mark as Duplicate under a cluster root that is itself a duplicate - #16988
blakeaowens wants to merge 2 commits into
Conversation
…s itself a duplicate The similar findings menu on the classic View Finding page offered Mark as Duplicate when the page finding's cluster root is itself a duplicate (a chain, or an orphan whose original is gone), and the mark route refused it. The menu now blocks the mark wherever the route refuses it: a root that is a duplicate, and the page finding or its root as the row. Set as Original and Reset Duplicate Status stay offered, since their routes accept them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GLL1WcuDZt6EY4UraiB5hr
Adversarial review (full tier): no blockers; R1 and R2 to fix before mergeReviewed at CI: all 49 checks pass (Rest Framework unit tests on both matrices, UI, k8s, performance, ruff). Not re-run. Fails without the fix: the new tests and Pro consumer: the Pro similar-findings suites that call this function (50 tests) pass with this head mounted. Break attempts (realistic cluster data from
|
… itself a duplicate Drop the page-finding and root id check from the Mark as Duplicate block: the branches below already answer both rows, and the check made the root row show the engagement reason instead of the root-of-cluster reason when the page finding sits in another engagement. A test pins the root row's reason. The docs and the mark route's refusal now point at what the UI offers in this case: Set as Original on the similar finding, or unchecking Duplicate on the original's Edit Finding page. Reset Duplicate Status is never offered on such a root's row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GLL1WcuDZt6EY4UraiB5hr
|
Review resolution, answering the verdict at #16988 (comment)
Test run at b555f86, OSS settings on Postgres: |
Description
On the classic View Finding page, the similar findings menu offered Mark as Duplicate on rows that the
mark_finding_duplicateroute then refused, whenever the page finding's cluster root is itself a duplicate:duplicate=Trueand noduplicate_finding. Its rows offered the same two actions, and the mark was refused the same way.A row that is a duplicate in another cluster offered Reset Duplicate Status and Mark as Duplicate under such a root, with the same refusal.
calculate_possible_related_actions_for_similar_findingnow addsmark_finding_duplicateto its blocked set (introduced in #16980) when the page finding's cluster root is itself a duplicate, as the route refuses it there. Set as Original stays offered: its route accepts it under such a root and leaves the cluster one level deep (a test posts it to confirm). Reset Duplicate Status stays offered as before.Test results
New tests in
unittests/test_mark_finding_duplicate_self_reference.py, each checking the menu and then posting the route:["set_finding_as_original"], and the posted mark is refused;["reset_finding_duplicate_status"], and the posted mark is refused;The mark route's refusal for this case now names the remedies the UI offers (Set as Original on the similar finding, or unchecking Duplicate on the original's Edit Finding page) instead of Reset Duplicate Status, which is never offered on such a root's row. Unchecking Duplicate there was measured: the root ends with
duplicate=False,duplicate_finding=None, and keeps its members.On
devfive of them fail (['mark_finding_duplicate', 'set_finding_as_original'] != ['set_finding_as_original'],['reset_finding_duplicate_status', 'mark_finding_duplicate'] != ['reset_finding_duplicate_status'], and'/finding/7/duplicate/3' unexpectedly foundon the page); with this change all pass.test_mark_finding_duplicate_self_referenceandtest_similar_finding_related_actionstogether: 40 tests, all pass with the change; ondevthe five menu and page tests fail. Neighbouring suites (test_bulk_finding_authorization,test_finding_model,test_finding_view_followups,test_manual_duplicate_onto_mitigated,test_permissions_audit,test_post_handler_permissions,test_prepare_duplicates_for_delete,test_read_only_mode) plus both modules: 308 tests at the current head. Ondev16 failed (305 tests at the time); with this change 11 fail; the 11 left are file upload and image token tests that fail identically ondevbecause the media directory was not writable in the test container (PermissionError: [Errno 13] Permission denied: '/media/uploaded_files').ruff check(0.16.10) passes on the changed files.Performance, View Finding for a duplicate under a chained root with 50 extra similar findings, two interleaved rounds each: 134 queries before and after (the check reads the root the function already loads). Wall time medians 452 and 439 ms on
dev, 421 and 412 ms with the change, within run-to-run noise. The rendered page drops from 12 Mark as Duplicate links to 0 and keeps all 19 Set as Original links.Documentation
OS__similar_findings.md: the Mark as duplicate entry now says it is not offered while the cluster's original is itself marked as a duplicate, and names the remedies: Set as original on the similar Finding, or unchecking Duplicate on that original's Edit Finding page.🤖 Generated with Claude Code
https://claude.ai/code/session_01GLL1WcuDZt6EY4UraiB5hr