fix(data-integrity): remove session.rollback() calls from ProjectRepository
Removed unconditional session.rollback() calls within exception handlers in: - ProjectRepository.create() - NamespacedProjectRepository.create() (IntegrityError handler) - NamespacedProjectRepository.create() (OperationalError handler) - NamespacedProjectRepository.update() - NamespacedProjectRepository.delete() The Unit of Work pattern already handles transaction rollback at the outer layer via its except Exception: session.rollback() handler, making these inner rollbacks redundant. SQLAlchemy automatically invalidates the transaction state when exceptions occur after flush(), preventing partial data from being committed. Removing the redundant rollbacks improves clarity, eliminates potential issues related to exception chaining across retry boundary layers, and aligns repository implementations with explicit transaction boundaries. ISSUES CLOSED: #8179
This commit is contained in:
@@ -146,3 +146,15 @@ Feature: Namespaced project repository operations
|
||||
When I remove the link by its stored id
|
||||
Then the remove result should be True
|
||||
And the removed link should be absent in a new session from the same engine
|
||||
|
||||
# ---------- Data integrity: rollback removal verification ----------
|
||||
|
||||
Scenario: IntegrityError raises DatabaseError through repository create method (no explicit rollback)
|
||||
Given a namespaced project "local/integrity-verify" exists in the repository
|
||||
When I create a namespaced project "local/integrity-verify" via the repository expecting an error
|
||||
Then the repository error type should be "DatabaseError"
|
||||
|
||||
Scenario: Update non-existent project raises ProjectNotFoundError without leaving transaction dirty
|
||||
Given a namespaced project "local/missing-update-check" exists in the repository
|
||||
When I update a non-existent project "local/missing-update-check" expecting an error
|
||||
Then the repository error should be "ProjectNotFoundError"
|
||||
|
||||
Reference in New Issue
Block a user