Repository navigation
[BREAKING] FIX: Reject stale finding edits - #4640
Open
Aman (its-amann) wants to merge 9 commits into
Open
Aman (its-amann) wants to merge 9 commits into
Aman (its-amann) wants to merge 9 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 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
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Aman (its-amann)
force-pushed
the
fix/finding-stale-updates-3736
branch
from
November 28, 2026 15:45
c6ed8d2 to
2411c16
Compare
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>
Roman Lutz (romanlutz)
enabled auto-merge
December 3, 2026 07:28
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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.
API clients must send the finding's returned
versionasexpected_versionwhen updating it. SDK callers must pass it asexpected_versiontoupdate_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.