Skip to content

fix(phase8/task46/h4): graceful skip for default chat collection without embedding model#1676

Merged
earayu merged 1 commit into
mainfrom
chenyexuan/phase8-task46-h4-graceful-skip
Apr 25, 2026
Merged

fix(phase8/task46/h4): graceful skip for default chat collection without embedding model#1676
earayu merged 1 commit into
mainfrom
chenyexuan/phase8-task46-h4-graceful-skip

Conversation

@earayu

@earayu earayu commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

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 ValueError noise

ChatCollectionService.create_user_chat_collection raised ValueError("No suitable embedding model found...") on no-provider users; caught (and silently logged as ERROR) by user_manager.py try/except. Replace with logger.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_databases unconditionally called get_collection_embedding_service_sync, even for collections with enable_vector=false (smoke 02_collection.hurl, KG-only tenants). When config.embedding is None, base_embedding.py:158 accessed .model_service_provider on NoneType → AttributeError → Celery retry storm.

Add an enable_vector guard symmetric with the existing enable_fulltext guard in _initialize_fulltext_index (one-line fix).

Scope discipline

  • aperag/tasks/collection.py 1-line guard = local bug fix, NOT a relocation. Option I scope-lock (no aperag/tasks/ integral migration) still holds — explicitly confirmed by @架构师 msg=1e845856.
  • aperag/domains/knowledge_base/service/collection_service.py was originally listed in canonical write set; analysis shows once _initialize_vector_databases is fixed at root, the collection_init_task retry 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 pass
  • uv run pytest tests/unit_test/test_modularization_boundaries.py — 21/21 pass (G1-G19 hard invariants intact)
  • uv run ruff format --check — clean
  • uv run ruff check — clean
  • Existing chat domain tests tests/unit_test/chat/ — 11/11 pass

Operational gates (architect msg=1e845856)

  • Registration flow no longer logs No suitable embedding model ERROR
  • Smoke compose log no longer emits NoneType.*model_service_provider Celery retry (root cause path closed by _initialize_vector_databases enable_vector guard)
  • tests/e2e_http/bootstrap/PROTOCOL.md unchanged (protocol itself was correct)

Test plan

  • Unit tests cover graceful skip for both registration and existing-collection paths
  • Unit tests cover _initialize_vector_databases short-circuit on enable_vector=false
  • Unit tests cover happy path (enable_vector=true with embedding) still resolves embedding service exactly once
  • CI lint-and-unit green
  • CI e2e-http-smoke no longer shows NoneType.*model_service_provider retry spam

Closes

Task #46 — Phase 8 第二批 H4 graceful skip for default chat collection without embedding model

🤖 Generated with Claude Code

…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>
@earayu earayu merged commit 28da5a5 into main Apr 25, 2026
0 of 2 checks passed
@earayu earayu deleted the chenyexuan/phase8-task46-h4-graceful-skip branch April 25, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant