fix(host-sweep): inject DbRw opener so in-memory tests don't fail silently#2210
Closed
robbyczgw-cla wants to merge 1 commit intoqwibitai:mainfrom
Closed
fix(host-sweep): inject DbRw opener so in-memory tests don't fail silently#2210robbyczgw-cla wants to merge 1 commit intoqwibitai:mainfrom
robbyczgw-cla wants to merge 1 commit intoqwibitai:mainfrom
Conversation
…ently resetStuckProcessingRows() reopens outbound.db by filesystem path via openOutboundDbRw(agent_group_id, session_id) to drop orphan processing claims after killing a stuck container. The 2 host-sweep regression tests (added in 7ce9922) call _resetStuckProcessingRowsForTesting with an in-memory outDb and a fakeSession() whose path doesn't exist on disk — the reopen fails, the error is silently caught, the orphan claim stays in place, and the assertion 'expect(getProcessingClaims(outDb)).toEqual([])' fails on a clean checkout. Make the rw-opener injectable. The test path passes () => outDb so the delete runs on the caller's handle; production keeps openOutboundDbRw as the default. Don't close the test-supplied handle in the finally — the caller still owns it. Verified: all 14 host-sweep.test.ts tests pass on clean upstream/main@953264e. Full suite remains green. Co-Authored-By: Andy (Claude Opus 4.7) <noreply@anthropic.com>
Contributor
Author
|
Closing as duplicate of #2209 — same bug (host-sweep regression tests fail because in-memory outDb gets reopened by filesystem path that does not exist for fakeSession()), same fix concept (make the rw-DB handle injectable for the test path). #2209 was opened first (4h prior) and has a marginally cleaner API (passes the DB directly vs. an opener function); going with that one. Apologies for the duplication — should have grep-checked open PRs before starting. |
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.
Summary
resetStuckProcessingRows()(called from the regression-protectedclaim-stuckpath) reopensoutbound.dbby filesystem path viaopenOutboundDbRw(agent_group_id, session_id)to drop orphan processing claims after killing a stuck container.The 2 host-sweep regression tests (
should clear orphan claims even when message is past process_afterandstill clears orphan claims even when the inbound message has already been retried (skip path), both added in 7ce9922) call_resetStuckProcessingRowsForTestingwith an in-memory outDb and afakeSession()whose path doesn't exist on disk — the reopen fails, the error is silently caught in thetry/catch, the orphan claim stays in place, and the assertionexpect(getProcessingClaims(outDb)).toEqual([])fails on a clean checkout.The bug is in the test fixture's contract with the function under test, not in the function's runtime behaviour. Production paths exist on disk, so the reopen succeeds there.
Fix
Make the rw-opener injectable.
_resetStuckProcessingRowsForTestingpasses() => outDbso the delete runs on the caller's handle; production keepsopenOutboundDbRwas the default. Don't close the test-supplied handle in thefinally— the caller still owns it.Verification
Tested on
upstream/main@953264e0(v2.0.27).Test plan