test: fix broken connection-error abort test from #47#52
Merged
Conversation
test_connection_error_aborts_without_checkpoint (added in #47) passed a Mock generation_session_service without configuring db_adapter. Because execute_all_phases derives `db_adapter = generation_session_service.db_adapter` and calls raise_if_cancelled() before each phase, the auto-Mock adapter made raise_if_cancelled await a non-awaitable Mock (get_generation_session), raising TypeError before the connection-error abort under test was ever reached. Set svc.db_adapter = None so raise_if_cancelled hits its documented DB-less no-op path (matching test/state/test_cancellation.py::test_noop_when_db_adapter_is_none), leaving the test to exercise only the checkpoint-abort behavior it asserts. Code under test is unchanged — this was a test-mocking gap at the seam with the pre-existing cancellation check, not a regression in error handling. Backend: 2040 passed / 36 skipped. mcp_server: 671 passed.
akozak-gd
approved these changes
Jul 23, 2026
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
Commit
57e956d(#47, graceful handling of transient API connection errors) left one unit test broken. This PR fixes that test. No production code is changed — the failure was a test-mocking gap, not a regression in the new error handling.The failure
make unit-tests→ backend:Raised at
app/services/claude_code.py:1206→raise_if_cancelled(db_adapter, ...)→app/state/cancellation.py:58await db_adapter.get_generation_session(...).Root cause
execute_all_phasesderivesdb_adapter = generation_session_service.db_adapterand runs a cooperative cancellation check (raise_if_cancelled) before each phase — code that predates #47 (added in the cancel-generation workflow). The new test in #47 passed a bareMock()service to assert on its checkpoint methods, but never setdb_adapter. So the auto-Mockattribute maderaise_if_cancelledawaita non-awaitable, blowing up before the connection-error abort the test is meant to verify.The sibling test (
test_connection_error_aborts_on_first_occurrence) passes only because it omits the service entirely (db_adapter=None→ documented no-op).The fix
Set
svc.db_adapter = Nonein the failing test, matching the documented DB-less unit-test path (test/state/test_cancellation.py::test_noop_when_db_adapter_is_none). The test then exercises exactly what it asserts: a connection error aborts the workspace without writing the phase checkpoint.Test evidence
make unit-tests— backendmake unit-tests— mcp_servermake integration-testsmake skip-mode-e2e-testsE2E_WORKSPACE_CONFIGunset / no config file) — prerequisite missing, suite not runThe two E2E/integration suites could not execute in this environment for reasons unrelated to the commit; only the unit suite surfaced a real defect, and it is now green.
🤖 Generated with Claude Code