Skip to content

[BREAKING] FIX: Reject stale finding edits - #4640

Open
Aman (its-amann) wants to merge 9 commits into
microsoft:mainfrom
its-amann:fix/finding-stale-updates-3736
Open

Aman (its-amann) wants to merge 9 commits into
microsoft:mainfrom
its-amann:fix/finding-stale-updates-3736

Conversation

@its-amann

@its-amann Aman (its-amann) commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Editing a finding from an older browser tab can overwrite changes saved in another tab. This rejects stale saves with HTTP 409 and leaves the draft open so the user can reconcile their edits.

  • Store an edit version on each finding and check it inside the existing write transaction.
  • Send the original version from the edit dialog and preserve the draft on conflicts.
  • Cover conflicting edits, simultaneous saves, and migration of existing findings.

API clients must send the finding's returned version as expected_version when updating it. SDK callers must pass it as expected_version to update_finding_async. After a 409, read the latest finding and reconcile changes before retrying.

Fixes #3736.

Roman Lutz (@romanlutz) this follows the version check approach you suggested.

Copilot AI 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.

🟡 Changes recommended

A frontend test fixture no longer satisfies the required FindingListItem type, and the migration cannot roll back on SQL Server because it leaves a dependent default constraint in place.

2 open issues
What changed in this PR

This PR adds version-based conflict detection to PyRIT’s finding-edit flow, addressing the stale-tab overwrites reported in #3736 across storage, the API, and the GUI.

Changes:

  • Persist finding versions and require them for updates, returning HTTP 409 for stale edits.
  • Send the original version from the edit dialog and preserve drafts after conflicts.
  • Add conflict and migration coverage, update existing fixtures, and document the breaking API/SDK contract.
File Description
tests/​unit/​memory/​test_findings.py Tests simultaneous edits and supplies expected versions.
tests/​unit/​memory/​test_finding_version_migration.py Tests version initialization, rollback, and SQL Server upgrade SQL.
tests/​unit/​memory/​test_finding_field_values_migration.py Upgrades to the latest revision before schema validation.
tests/​unit/​memory/​test_finding_decomposition.py Supplies versions in hierarchy-edit tests.
tests/​unit/​backend/​test_operations.py Covers stale edits, reconciliation, and version validation.
tests/​unit/​backend/​test_operation_service_findings.py Tests conflicts between service reads and writes.
tests/​unit/​backend/​test_operation_finding_tree.py Includes versions in editable finding payloads.
tests/​unit/​backend/​test_common_models.py Updates request-validation fixtures with versions.
pyrit/​models/​finding.py Adds the shared finding version field.
pyrit/​memory/​memory_models.py Persists and returns finding versions.
pyrit/​memory/​memory_interface.py Checks and increments versions during updates.
pyrit/​memory/​alembic/​versions/​8c2d4e6f0a13_version_finding_edits.py Adds the version column with an initial value of one.
pyrit/​backend/​services/​operation_service.py Validates versions and maps stale writes to conflicts.
pyrit/​backend/​routes/​operations.py Documents version requirements and conflict responses.
pyrit/​backend/​models/​operations.py Requires a positive integer version in update requests.
frontend/​src/​types/​index.ts Adds versions to finding and update interfaces.
frontend/​src/​services/​api.test.ts Includes a version in the update-request test.
frontend/​src/​components/​Scenarios/​ScenarioRunPage.test.tsx Adds a version to the linked-finding fixture.
frontend/​src/​components/​Operations/​OperationDetailPage.tsx Sends the finding’s original version when saving.
frontend/​src/​components/​Operations/​OperationDetailPage.test.tsx Verifies draft and version preservation after conflicts.
frontend/​src/​components/​Operations/​FindingPathsDialog.test.tsx Adds a version to the finding fixture.
frontend/​src/​components/​Chat/​FindingEvidenceDialog.test.tsx Adds a version to the evidence-dialog fixture.
frontend/​src/​components/​Chat/​AttachToFindingsButton.test.tsx Adds a version to the attachment fixture.
doc/​gui/​0_gui.md Explains conflict recovery and API/SDK version requirements.

Review effort: Balanced

Comment thread frontend/src/types/index.ts Resolved
@its-amann
Aman (its-amann) force-pushed the fix/finding-stale-updates-3736 branch from c6ed8d2 to 2411c16 Compare November 28, 2026 15:45
@its-amann

Copy link
Copy Markdown
Contributor Author

Roman Lutz (@romanlutz) added mssql_drop_default=True and version 1 in the test fixture, plus a migration regression test. should be good for review now

…e conflict message

Matches the scenario preset/suite optimistic-concurrency naming. The
user-facing conflict wording now lives only in the operation service;
the memory layer reports the version mismatch itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Main gained the planned-media branch and its merge migration while this
PR was open, leaving two alembic heads. A no-op merge revision joins
them, as main did for the planned-media branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces the no-op merge revision: its parent was itself a merge, which
the SQL Server round-trip check cannot step back through. Roman approved
skipping the local immutability hook for this unmerged migration; the CI
check diffs against main, where the migration is still an addition.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editing a finding in a stale browser tab overwrites another tab's changes to fields the user did not edit

3 participants