fix(phase8/task46/h4): graceful skip for default chat collection without embedding model#1676
Merged
Merged
Conversation
…out embedding model Closes the two related provider-independence bugs surfaced by weihong's #41 H4 inventory (msg=1f04e57a). Bug 1 — registration flow ValueError noise: ChatCollectionService.create_user_chat_collection raised ValueError when no provider was configured, swallowed by user_manager but logged as ERROR. Replace with logger.info + return None (graceful skip); upload_chat_document caller surfaces a 400 instead. Bug 2 — smoke Celery NoneType retry storm (root cause): CollectionTask._initialize_vector_databases unconditionally called get_collection_embedding_service_sync, even for collections with enable_vector=false (smoke 02_collection.hurl, KG-only tenants). config.embedding is None → AttributeError on model_service_provider → Celery retry storm. Add an enable_vector guard symmetric with the existing enable_fulltext guard in _initialize_fulltext_index. Per architect canonical msg=8b6b4bc3 (Option α — graceful degradation) refined by msg=2c4f4d8c (Option H4-B — both Bug 1 and Bug 2 in one PR). aperag/tasks/collection.py 1-line guard is a local bug fix; Option I scope (no aperag/tasks/ relocation) still holds. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
H4 (task #46) graceful degradation for provider-independent flows, per architect canonical msg=8b6b4bc3 (Option α) and msg=2c4f4d8c (Option H4-B refined).
Closes the two related bugs surfaced by @weihong #41 H4 inventory (msg=1f04e57a):
Bug 1 — registration flow
ValueErrornoiseChatCollectionService.create_user_chat_collectionraisedValueError("No suitable embedding model found...")on no-provider users; caught (and silently logged as ERROR) byuser_manager.pytry/except. Replace withlogger.info+return None(graceful skip). The single non-registration caller (chat_document_service.upload_chat_document) surfaces an HTTP 400 instead — chat document upload genuinely needs an embedding model.Bug 2 — smoke Celery NoneType retry storm (root cause)
CollectionTask._initialize_vector_databasesunconditionally calledget_collection_embedding_service_sync, even for collections withenable_vector=false(smoke02_collection.hurl, KG-only tenants). Whenconfig.embeddingisNone,base_embedding.py:158accessed.model_service_provideronNoneType→ AttributeError → Celery retry storm.Add an
enable_vectorguard symmetric with the existingenable_fulltextguard in_initialize_fulltext_index(one-line fix).Scope discipline
aperag/tasks/collection.py1-line guard = local bug fix, NOT a relocation. Option I scope-lock (noaperag/tasks/integral migration) still holds — explicitly confirmed by @架构师 msg=1e845856.aperag/domains/knowledge_base/service/collection_service.pywas originally listed in canonical write set; analysis shows once_initialize_vector_databasesis fixed at root, thecollection_init_taskretry pipeline stays generic (transient errors should still retry). Not modified.Gate
uv run pytest tests/unit_test/chat/test_chat_collection_graceful_skip.py tests/unit_test/tasks/test_collection_init_skip.py— 5/5 passuv run pytest tests/unit_test/test_modularization_boundaries.py— 21/21 pass (G1-G19 hard invariants intact)uv run ruff format --check— cleanuv run ruff check— cleantests/unit_test/chat/— 11/11 passOperational gates (architect msg=1e845856)
No suitable embedding modelERRORNoneType.*model_service_providerCelery retry (root cause path closed by_initialize_vector_databasesenable_vector guard)tests/e2e_http/bootstrap/PROTOCOL.mdunchanged (protocol itself was correct)Test plan
_initialize_vector_databasesshort-circuit onenable_vector=falseenable_vector=truewith embedding) still resolves embedding service exactly oncelint-and-unitgreene2e-http-smokeno longer showsNoneType.*model_service_providerretry spamCloses
Task #46 — Phase 8 第二批 H4 graceful skip for default chat collection without embedding model
🤖 Generated with Claude Code