Fix flaky DeleteInvisibleLanesScript test#3043
Merged
jonathangreen merged 2 commits intomainfrom Feb 11, 2026
Merged
Conversation
…fore deleting The Lane.visible property is computed recursively, checking parent visibility. When the script interleaved _db.delete() calls with visibility checks in the same loop, deleting a parent could trigger an autoflush during a child's parent lazy-load, nullifying parent_id and making the child appear visible. Separating evaluation from deletion ensures consistent visibility checks.
828d11e to
d578a39
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3043 +/- ##
=======================================
Coverage 93.04% 93.04%
=======================================
Files 480 480
Lines 43711 43712 +1
Branches 6029 6028 -1
=======================================
+ Hits 40669 40670 +1
Misses 1972 1972
Partials 1070 1070 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Fix the flaky
TestDeleteInvisibleLanesScript::test_do_runtest by evaluating lane visibility before performing any deletions.Motivation and Context
Lane.visibleis a computed property that recursively checks parent visibility:self._visible and (not self.parent or self.parent.visible). When the original script interleaved_db.delete()calls withvisiblechecks in the same loop, deleting a parent lane could trigger a SQLAlchemy autoflush when a child subsequently lazy-loaded itsparentrelationship. The autoflush would execute the pending DELETE and setparent_id = NULLon children, causingchild.visibleto returnTrue, so the script would skip deleting the child.This caused the test to be flaky, but could also cause the script to be flaky as well. The fix separates evaluation from mutation — all visibility checks happen before any
_db.delete()calls, ensuring consistent parent references.Example CI failure: https://github.com/ThePalaceProject/circulation/actions/runs/21918135183/job/63290798573
How Has This Been Tested?
Existing test
TestDeleteInvisibleLanesScript::test_do_runcovers this behavior and should now pass consistently.Checklist