Repository navigation
fix: patch _Server in workflows entrypoint tests (#9675) - #9682
Conversation
|
Intent: Make the two workflows entrypoint tests substitute the class main() actually constructs, so they never bind a real socket — unblocking Backend Tests shard 4 for every PR on main. |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — ✅ PASSDesign-level review of Verified against source: Design-Verdict: PASS Test-only root-cause fix: patches the class [DESIGN-REVIEWED] 73a3a81 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
Heads-up: Backend Lint & Type Check (3.12) is red on this head — that one is from this PR's own change (the |
test_main_boots_platform_before_binding_server monkeypatched server.ThreadingHTTPServer, but main() constructs _Server, whose base class was bound at class-definition time - the patch never engaged, so the test booted a real listener on the real PORT and blocked forever in serve_forever(), hanging Backend Tests shard 4 on every PR (120s timeout on Linux, xdist worker crash on Windows, Coverage Gate cascade). Patch server._Server (the name main() actually resolves) instead, in both this test and test_main_fails_closed_when_platform_cannot_compose, whose identical patch was dead but masked by its raising boot stub. monkeypatch.setattr raises on a missing attribute, so a future rename of _Server fails fast instead of hanging. Both tests also arm a name-independent guard that patches socketserver.TCPServer.server_bind to pytest.fail, so any future construction path the named patch misses fails loudly at the bind instead of hanging the shard, and the fail-closed test uses a class-shaped fake so an ordering regression reports the ordering assertion rather than an unrelated AttributeError. The production code is correct; this is a test-only semantic merge collision between #9066 and #9413, whose CI rounds each ran on a merge ref predating the other. Closes #9675
f1285c5 to
73a3a81
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: NicholasRBowers#a942f9ca] Thanks for the heads-up, @CrysisDeu. The Backend Lint red you saw was on the prior head (a comment-history-gate hit on the |
chenmingwei23
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean (Semgrep success 0 ann, CodeQL success 0 alerts), security checklist all-NO, AI reviewers green. Category: test-only change to test/test_workflows_app.py (patches _Server in workflows entrypoint tests).
dwu96
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: test-only change confined to test/test_workflows_app.py — substitutes the class the entrypoint actually constructs and adds a bind guard so the tests cannot open a real listener; no runtime code touched.
…irodotdev#9682) test_main_boots_platform_before_binding_server monkeypatched server.ThreadingHTTPServer, but main() constructs _Server, whose base class was bound at class-definition time - the patch never engaged, so the test booted a real listener on the real PORT and blocked forever in serve_forever(), hanging Backend Tests shard 4 on every PR (120s timeout on Linux, xdist worker crash on Windows, Coverage Gate cascade). Patch server._Server (the name main() actually resolves) instead, in both this test and test_main_fails_closed_when_platform_cannot_compose, whose identical patch was dead but masked by its raising boot stub. monkeypatch.setattr raises on a missing attribute, so a future rename of _Server fails fast instead of hanging. Both tests also arm a name-independent guard that patches socketserver.TCPServer.server_bind to pytest.fail, so any future construction path the named patch misses fails loudly at the bind instead of hanging the shard, and the fail-closed test uses a class-shaped fake so an ordering regression reports the ordering assertion rather than an unrelated AttributeError. The production code is correct; this is a test-only semantic merge collision between kirodotdev#9066 and kirodotdev#9413, whose CI rounds each ran on a merge ref predating the other. Closes kirodotdev#9675 Co-authored-by: Nick Bowers <nrb@amazon.com>
Problem / Motivation
URGENT — every PR based on current main is red. Backend Tests shard 4 hangs on
test/test_workflows_app.py::test_main_boots_platform_before_binding_server: a 120s pytest timeout on Linux 3.12, an xdist worker crash on Windows, and the Coverage Gate cascades red because the shard never uploads. The test monkeypatchesserver.ThreadingHTTPServer, butmain()constructsserver._Server— a subclass whose base was bound at class-definition time — so the patch never engages and the test boots a real listener on the realPORT, then blocks forever inserve_forever().Why it matters
The whole repository is blocked: no PR can go green until this lands, and the failure shape is the worst kind — a silent hang with no test output to diagnose from. It was a semantic merge collision: #9066 added the test, #9413 introduced
_Server, each PR's CI ran on a merge ref predating the other, so both were green alone and red combined.What changed (motivation → approach → change)
The test hung because it patched a name
main()no longer reads. The fix (test-only — the production code is correct) patchesserver._Server, the classmain()actually constructs, in bothtest_main_boots_platform_before_binding_serverandtest_main_fails_closed_when_platform_cannot_compose, whose identical patch was dead but masked by its raising boot stub.monkeypatch.setattrraises on a missing attribute, so a rename of_Serverfails fast.A named patch alone cannot survive the exact vector that caused this incident —
main()constructing the listener under a name the test does not patch. Both tests therefore also arm a name-independent guard:socketserver.TCPServer.server_bindis patched topytest.fail, so any unsubstituted construction path fails loudly at the bind instead of hanging the shard. The fail-closed test's fake is class-shaped (withserve_forever) so an ordering regression reports the ordering assertion, not an unrelatedAttributeErroronNone.Tests
test_main_boots_platform_before_binding_server— the boot→bind→serve ordering assertion is unchanged; the patch now engages. Red-before-green demonstrated locally: on unpatched main the test hangs until pytest-timeout kills the xdist worker (the exact CI signature); with the fix, the file's 34 tests pass in ~6s.test_main_fails_closed_when_platform_cannot_compose— same substitution; its previously-dead patch is now live, andserved == []still locks the fail-closed invariant.server_bindguard was mutation-verified: re-introducing the deadThreadingHTTPServerpatch with the guard armed fails immediately with "main() bound a real socket" instead of hanging.test/test_workflows_app.pyplussrc/kiro_crew/apps/builtins/workflows/testsgreen on Python 3.12.Manual verification
N/A — unit coverage sufficient: the defect and fix are both fully contained in the two entrypoint tests, and the red-before-green run reproduced the CI hang signature locally.
Related Issues
Closes #9675
Pattern harvest
Rule candidate: review-prompt
Pattern: monkeypatching a base-class name never intercepts a subclass bound at class-definition time — patch the name the code under test actually constructs, and back socket-touching entrypoint tests with a bind-level tripwire.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)