You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Backend unit suite red on main: ModuleNotFoundError models.client_processing in merge suites (import-isolation ordering) #12779
Backend unit suite is red on main and takes every open PR with it. The failure is an ordering effect, not a missing file.
Symptom
Setup ERROR, not a test failure, in the merge-related suites:
tests/unit/test_merge_validation.py ERROR
tests/unit/test_batch_upload_storage.py ERROR
tests/unit/test_merge_deleted_source_race.py ERROR
E ModuleNotFoundError: No module named 'models.client_processing'
utils/conversations/projection_payload.py:19: ModuleNotFoundError
Evidence it is main, not a branch
main @ 23156505 — run 33946681309, failing with this exact error.
So the import resolves fine on its own. It only fails in the full-suite ordering, which points at import isolation: something earlier in the run replaces or partially stubs models in sys.modules, and utils/conversations/projection_payload.py imports models.client_processing at module import time, so the stub is what it sees.
Why it is worth fixing rather than re-running
The failure is ordering-dependent, so a re-run can look green and hide it. In the meantime it is a required check, so it blocks unrelated PRs and trains people to treat a red Backend unit suite as noise — which is the expensive part.
Two directions, whichever the owner of that area prefers: have the stubbing test restore sys.modules (or scope its stub), or make projection_payload import models.client_processing lazily so a stubbed models package cannot break collection for unrelated suites.
I have not touched it — this sits in the conversations/merge area rather than anything I have open, and the fix should come from whoever owns that isolation harness.
Still red, and now on two consecutive main commits — so this is not a one-off flake in the ordering.
main commit
Backend unit suite
cfa5c1cb
success
7c0e4361
success
23156505
failure
09ff17e4
failure
Both failures are the same ModuleNotFoundError: No module named 'models.client_processing' raised from utils/conversations/projection_payload.py:19 during collection of tests/unit/test_batch_upload_storage.py and tests/unit/test_merge_validation.py.
It is now blocking unrelated PRs that cannot do anything about it. Two of mine, whose diffs do not touch any path in the failure:
Neither can turn the check green by merging main, because main is where it is red.
The suspect window is between 7c0e4361 and 23156505. Since the tests pass in isolation and fail only in the full-suite ordering, the likely culprit is a test that stubs or partially replaces models in sys.modules without restoring it, combined with projection_payload.py importing models.client_processing at module import time — so collection of a later suite sees the stub rather than the real package.
Happy to bisect that window and send a fix if nobody who owns the conversations/merge isolation harness is already on it — say the word rather than both of us doing it.
Some triage for whoever picks this up. I tried to find the polluter and did not, but I eliminated the obvious suspects, so the next person need not repeat this.
Still failing.main is red across multiple commits now (23156505, 09ff17e4, 2cdb89f5), and it has failed the same required check on approved PRs repeatedly — #12748 has been flagged three times.
Ordering constraint. The CI runner walks tests/unit/ alphabetically, so the polluter sorts before test_batch_upload_storage.py. That bounds the search to roughly the first 104 files.
The obvious suspects are not it. Five suites reach into sys.modules['models']:
tests/unit/test_sync_silent_failure.py:751 sys.modules['models'].__path__ = []
tests/unit/test_action_item_date_validation.py __path__ = [BACKEND_DIR/"models"]
tests/unit/test_conversation_structure_timezone.py same
tests/unit/test_prompt_cache_integration.py same
tests/unit/test_desktop_transcribe.py:121 _models_pkg = sys.modules['models']
test_sync_silent_failure.py looks damning — an empty __path__ makes every models.* submodule unimportable, which is exactly this error. It is not the cause: it stubs modelsafter saving the original, mutates only the stub, and teardown_class restores. Pairing each of these ten files with test_merge_validation.py reproduces nothing:
$ for f in $(grep -rln "sys.modules\[.models" tests/); do
pytest "$f" tests/unit/test_merge_validation.py -q -p no:randomly ...
done
# no ModuleNotFoundError from any pair
So it is either an interaction needing more than two files, or something that stubs utils.conversations / models.client_processing rather than the models package.
What I could not do. Running the alphabetical prefix (104 files) in one local process crashes the interpreter for unrelated reasons, so I could not reproduce the CI ordering locally to bisect it properly.
Worth considering regardless of the root cause:utils/conversations/projection_payload.py imports models.client_processing at module import time. Making that import lazy would stop any models stubbing anywhere from breaking collection of unrelated suites — a narrower blast radius than chasing each polluter as it appears. That is a call for whoever owns the module, not something I want to change from outside it.
Not taking this further — it sits in the conversations/merge isolation harness and I would rather leave it to someone who owns that code than keep guessing at it from the outside. Flagging the impact honestly though: it is currently blocking approved PRs that cannot do anything about it.
Correcting my triage above — it was wrong, and wrong for an embarrassing reason.
I ran that entire investigation in a worktree that was 372 commits behind main, sitting on an unrelated commit. utils/conversations/projection_payload.py did not even exist in it. That is why the polluter sweep "found nothing" and why the 104-file prefix crashed the interpreter — neither result was about this bug.
On a correct checkout of main, the same sweep finds the polluters immediately:
$ for f in $(grep -rln "sys.modules\[.models" tests/); do
pytest "$f" tests/unit/test_merge_validation.py -q -p no:randomly ...
done
POLLUTER: tests/unit/test_sync_silent_failure.py
POLLUTER: tests/unit/test_payment_promotion_codes.py
POLLUTER: tests/unit/test_sync_cloud_tasks.py
POLLUTER: tests/unit/test_sync_v2.py
POLLUTER: tests/unit/test_conversation_jit_processing.py
POLLUTER: tests/unit/test_sync_opus_decode.py
POLLUTER: tests/unit/test_sync_pcm_decode.py
Seven, not zero. So please disregard "the obvious suspects are not it" — that conclusion was an artifact of the stale tree, as was my claim that the erroring suites "pass in isolation on clean main".
Given seven polluters and nothing preventing an eighth, auditing each one's teardown is the whack-a-mole option. #12785 takes the other route and defers the models.client_processing import into strip_client_processing, its only consumer, so no models stub anywhere can break collection of that module.
That also restores what the module already claimed to be — its docstring says it lives outside process_conversation specifically so importing it "must not drag in the coordinator's module graph". A module-scope import of a models submodule was the same mistake one level down.
Every polluter, paired with the two erroring suites, now collects and runs; the same pairings produce 40 collection errors before the change. The regression test installs the same bare stub those suites use and is mutation-checked — restoring the module-scope import fails it with the exact production error at the exact line.
Two things this does not settle
I still cannot reproduce CI's full-suite ordering locally, so I am not claiming #12785 turns the check green — only that the failure mode is removed at its source. CI is the authority.
A second, unrelated pollution is now visible. With collection fixed, test_sync_opus_decode / test_sync_pcm_decode running before test_batch_upload_storage leak MagicMocks for utils.other.storage, giving assert 0 == 1 on upload_audio_chunks_batch. Those tests never executed before — they died at collection — so this is pre-existing breakage becoming visible rather than a regression. In alphabetical order test_batch_upload_storage sorts before both, so the triggering direction should not arise in CI; flagging it rather than asserting it cannot.
CI has now confirmed the fix, so the blocker on this PR has a verified remedy rather than a candidate.
#12785's Backend unit suite is green — run 33961213829, 3m29s, with 1072 backend unit test files selected and zero occurrences of No module named 'models.client_processing'. The same required check is red with that exact error on every other open PR, including this one.
Root cause, for the record: utils/conversations/projection_payload.py imported models.client_processing at module scope, and seven suites under tests/unit replace sys.modules['models'] with a bare stub. While one of those stubs is installed, merely collecting a later module that reaches it dies — which is why the error surfaces on test_batch_upload_storage / test_merge_validation rather than on whatever caused it. #12785 defers that import to its only consumer, so no models stub anywhere can break collection.
Nothing changes on this PR. Once #12785 lands, a merge of main here should turn the check green.
#12785 deferred the module-scope from models.client_processing import PROJECTION_FAMILY_FIELDS into strip_client_processing, and merged to main on 2026-09-05 at 11:38Z.
Confirmed at main today rather than assumed:
backend/utils/conversations/projection_payload.py no longer contains a module-scope from models.client_processing import (grep count 0).
The last six repo-checks runs on main are all success — most recently 492a563f at 11:17Z today.
The root cause, for the record: seven suites in tests/unit replace sys.modules['models'] with a stub. A module-scope import in projection_payload.py then made merely collecting later alphabetically-sorted suites fail — test_batch_upload_storage.py and test_merge_validation.py — even though neither imports that module. Deferring the import to call time resolves it after the stub is torn down. The regression test in test_client_processing_acceptance.py evicts both modelsandmodels.client_processing from sys.modules; evicting only the first made the test vacuous.
One related finding, filed separately rather than reopening this: the same class of leak exists between testing/contracts/test_desktop_backend_parity.py and tests/unit/test_batch_upload_storage.py (AttributeError: <module 'utils.other.storage'> has no attribute 'storage_client'). It reproduces with main's own copy of the contract file, and CI never sees it because contracts and unit run as separate jobs.
Activity
aryanorastar commentedon Sep 5, 2026
Still red, and now on two consecutive
maincommits — so this is not a one-off flake in the ordering.maincommitcfa5c1cb7c0e43612315650509ff17e4Both failures are the same
ModuleNotFoundError: No module named 'models.client_processing'raised fromutils/conversations/projection_payload.py:19during collection oftests/unit/test_batch_upload_storage.pyandtests/unit/test_merge_validation.py.It is now blocking unrelated PRs that cannot do anything about it. Two of mine, whose diffs do not touch any path in the failure:
backend/pyrightconfig.jsonandbackend/tests/.import_time_side_effects_legacy. Already approved; the red check is the only thing outstanding.backend/utils/other/notifications.pyplus two daily-summary/async-http test files and a failure-class JSON.Neither can turn the check green by merging
main, becausemainis where it is red.The suspect window is between
7c0e4361and23156505. Since the tests pass in isolation and fail only in the full-suite ordering, the likely culprit is a test that stubs or partially replacesmodelsinsys.moduleswithout restoring it, combined withprojection_payload.pyimportingmodels.client_processingat module import time — so collection of a later suite sees the stub rather than the real package.Happy to bisect that window and send a fix if nobody who owns the conversations/merge isolation harness is already on it — say the word rather than both of us doing it.
aryanorastar commentedon Sep 5, 2026
Some triage for whoever picks this up. I tried to find the polluter and did not, but I eliminated the obvious suspects, so the next person need not repeat this.
Still failing.
mainis red across multiple commits now (23156505,09ff17e4,2cdb89f5), and it has failed the same required check on approved PRs repeatedly — #12748 has been flagged three times.Ordering constraint. The CI runner walks
tests/unit/alphabetically, so the polluter sorts beforetest_batch_upload_storage.py. That bounds the search to roughly the first 104 files.The obvious suspects are not it. Five suites reach into
sys.modules['models']:test_sync_silent_failure.pylooks damning — an empty__path__makes everymodels.*submodule unimportable, which is exactly this error. It is not the cause: it stubsmodelsafter saving the original, mutates only the stub, andteardown_classrestores. Pairing each of these ten files withtest_merge_validation.pyreproduces nothing:So it is either an interaction needing more than two files, or something that stubs
utils.conversations/models.client_processingrather than themodelspackage.What I could not do. Running the alphabetical prefix (104 files) in one local process crashes the interpreter for unrelated reasons, so I could not reproduce the CI ordering locally to bisect it properly.
Worth considering regardless of the root cause:
utils/conversations/projection_payload.pyimportsmodels.client_processingat module import time. Making that import lazy would stop anymodelsstubbing anywhere from breaking collection of unrelated suites — a narrower blast radius than chasing each polluter as it appears. That is a call for whoever owns the module, not something I want to change from outside it.Not taking this further — it sits in the conversations/merge isolation harness and I would rather leave it to someone who owns that code than keep guessing at it from the outside. Flagging the impact honestly though: it is currently blocking approved PRs that cannot do anything about it.
aryanorastar commentedon Sep 5, 2026
Correcting my triage above — it was wrong, and wrong for an embarrassing reason.
I ran that entire investigation in a worktree that was 372 commits behind
main, sitting on an unrelated commit.utils/conversations/projection_payload.pydid not even exist in it. That is why the polluter sweep "found nothing" and why the 104-file prefix crashed the interpreter — neither result was about this bug.On a correct checkout of
main, the same sweep finds the polluters immediately:Seven, not zero. So please disregard "the obvious suspects are not it" — that conclusion was an artifact of the stale tree, as was my claim that the erroring suites "pass in isolation on clean main".
Fix: #12785
Given seven polluters and nothing preventing an eighth, auditing each one's teardown is the whack-a-mole option. #12785 takes the other route and defers the
models.client_processingimport intostrip_client_processing, its only consumer, so nomodelsstub anywhere can break collection of that module.That also restores what the module already claimed to be — its docstring says it lives outside
process_conversationspecifically so importing it "must not drag in the coordinator's module graph". A module-scope import of amodelssubmodule was the same mistake one level down.Every polluter, paired with the two erroring suites, now collects and runs; the same pairings produce 40 collection errors before the change. The regression test installs the same bare stub those suites use and is mutation-checked — restoring the module-scope import fails it with the exact production error at the exact line.
Two things this does not settle
I still cannot reproduce CI's full-suite ordering locally, so I am not claiming #12785 turns the check green — only that the failure mode is removed at its source. CI is the authority.
A second, unrelated pollution is now visible. With collection fixed,
test_sync_opus_decode/test_sync_pcm_decoderunning beforetest_batch_upload_storageleakMagicMocks forutils.other.storage, givingassert 0 == 1onupload_audio_chunks_batch. Those tests never executed before — they died at collection — so this is pre-existing breakage becoming visible rather than a regression. In alphabetical ordertest_batch_upload_storagesorts before both, so the triggering direction should not arise in CI; flagging it rather than asserting it cannot.aryanorastar commentedon Sep 5, 2026
CI has now confirmed the fix, so the blocker on this PR has a verified remedy rather than a candidate.
#12785's
Backend unit suiteis green — run 33961213829, 3m29s, with1072 backend unit test files selectedand zero occurrences ofNo module named 'models.client_processing'. The same required check is red with that exact error on every other open PR, including this one.Root cause, for the record:
utils/conversations/projection_payload.pyimportedmodels.client_processingat module scope, and seven suites undertests/unitreplacesys.modules['models']with a bare stub. While one of those stubs is installed, merely collecting a later module that reaches it dies — which is why the error surfaces ontest_batch_upload_storage/test_merge_validationrather than on whatever caused it. #12785 defers that import to its only consumer, so nomodelsstub anywhere can break collection.Nothing changes on this PR. Once #12785 lands, a merge of
mainhere should turn the check green.aryanorastar commentedon Sep 6, 2026
Fixed and verified on
main— closing.#12785 deferred the module-scope
from models.client_processing import PROJECTION_FAMILY_FIELDSintostrip_client_processing, and merged tomainon 2026-09-05 at 11:38Z.Confirmed at
maintoday rather than assumed:backend/utils/conversations/projection_payload.pyno longer contains a module-scopefrom models.client_processing import(grep count 0).repo-checksruns onmainare allsuccess— most recently492a563fat 11:17Z today.The root cause, for the record: seven suites in
tests/unitreplacesys.modules['models']with a stub. A module-scope import inprojection_payload.pythen made merely collecting later alphabetically-sorted suites fail —test_batch_upload_storage.pyandtest_merge_validation.py— even though neither imports that module. Deferring the import to call time resolves it after the stub is torn down. The regression test intest_client_processing_acceptance.pyevicts bothmodelsandmodels.client_processingfromsys.modules; evicting only the first made the test vacuous.One related finding, filed separately rather than reopening this: the same class of leak exists between
testing/contracts/test_desktop_backend_parity.pyandtests/unit/test_batch_upload_storage.py(AttributeError: <module 'utils.other.storage'> has no attribute 'storage_client'). It reproduces withmain's own copy of the contract file, and CI never sees it because contracts and unit run as separate jobs.