WeKnora/internal/handler
ochan.kwon 0e8de6192c feat(knowledge-base): validate vector store bindings on create, copy, and delete
Wires KnowledgeBase.VectorStoreID and the ownership-aware retrieve factory
into the user-facing knowledge-base lifecycle:

- POST /knowledge-bases validates the requested vector_store_id against
  the caller's tenant scope and the engine registry. New error codes
  ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable (2201)
  distinguish the typed branches without echoing UUIDs to the client.
- GET / POST / PUT / PUT-pin responses embed the bound store's display
  metadata (name, source, engine_type, status) without exposing any
  connection credentials. Cross-tenant shared KBs receive a suppressed
  payload (vector_store_id stripped, source="shared") so operator-chosen
  store names cannot be enumerated across tenants.
- POST /knowledge-bases/copy synchronously rejects clones whose target
  has a different embedding model or vector store, before the async
  clone task is enqueued. The async clone worker re-applies the same
  checks for defense in depth.
- DELETE /vector-stores/:id refuses to remove a store with bound KBs,
  inside a transaction that row-locks the store on PostgreSQL and
  serializes via WAL on SQLite. unregister-from-registry is wrapped in
  defer/recover so a panic surfaces as a structured warning instead of
  silently leaking a stale engine.
- vector_store_id is immutable after creation. The GORM <-:create tag
  blocks every ORM update path; the service-layer DTO omits the field
  entirely; a reflection-based regression test catches any future
  maintainer who adds it back to either layer.
- Empty-string vector_store_id is normalized to nil at both the create
  path and inside SharesStoreWith, so rows persisted by callers that
  did not run Normalize first cannot trip false same-store comparisons.

Part of #993. Depends on #994 and #1310.
2026-05-18 15:58:46 +08:00
..
dto refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
session fix(session): map ErrSessionNotFound to 404 across all handlers 2026-05-14 16:47:36 +08:00
auth.go feat: implement auto-setup for Lite edition, enhancing user experience by automating user and tenant creation on first launch 2026-04-11 18:51:16 +08:00
chunk.go feat(api): enhance organization shared knowledge base and agent functionalities 2026-02-09 11:40:25 +08:00
chunker_debug.go docs(api): add and fix swag annotations on handlers 2026-05-12 13:16:58 +08:00
chunker_debug_test.go fix(chunker): post-review fixes for preview endpoint robustness 2026-05-06 17:17:07 +08:00
custom_agent.go fix(agent): improve tenant context handling and error reporting 2026-04-24 22:40:57 +08:00
datasource.go refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
datasource_credentials.go refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
evaluation.go feat: 新增API Key认证支持,优化Swagger文档安全配置 2025-12-22 15:01:09 +08:00
faq.go fix(kb): map ErrKnowledgeBaseNotFound to 404 across handler helpers 2026-05-14 20:12:41 +08:00
im.go docs(api): add and fix swag annotations on handlers 2026-05-12 13:16:58 +08:00
initialization.go fix(initialization): surface upstream and SSRF errors verbatim in test-connection responses 2026-05-17 15:27:52 +08:00
knowledge.go fix(initialization): surface upstream and SSRF errors verbatim in test-connection responses 2026-05-17 15:27:52 +08:00
knowledgebase.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
knowledgebase_copy_preflight_test.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
knowledgebase_not_found_test.go fix(kb): map ErrKnowledgeBaseNotFound to 404 across handler helpers 2026-05-14 20:12:41 +08:00
knowledgebase_pr3_response_test.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
knowledgebase_request_test.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
mcp_credentials.go refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
mcp_service.go fix(initialization): surface upstream and SSRF errors verbatim in test-connection responses 2026-05-17 15:27:52 +08:00
message.go fix(session): map ErrSessionNotFound to 404 across all handlers 2026-05-14 16:47:36 +08:00
message_session_not_found_test.go fix(session): map ErrSessionNotFound to 404 across all handlers 2026-05-14 16:47:36 +08:00
model.go fix(initialization): surface upstream and SSRF errors verbatim in test-connection responses 2026-05-17 15:27:52 +08:00
model_credentials.go refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
organization.go docs(api): add and fix swag annotations on handlers 2026-05-12 13:16:58 +08:00
skill_handler.go feat: update sandbox service configuration in Docker Compose files 2026-02-04 21:34:07 +08:00
storage_allowlist.go feat(ks3): add KS3 object storage support 2026-05-05 00:22:27 +08:00
system.go fix(initialization): surface upstream and SSRF errors verbatim in test-connection responses 2026-05-17 15:27:52 +08:00
tag.go fix(kb): map ErrKnowledgeBaseNotFound to 404 across handler helpers 2026-05-14 20:12:41 +08:00
tenant.go fix(web-search): normalize default tenant web search config at runtime 2026-04-30 15:28:35 +08:00
vectorstore.go feat: add VectorStore CRUD API endpoints and documentation 2026-04-14 17:34:57 +08:00
web_search.go docs(api): add and fix swag annotations on handlers 2026-05-12 13:16:58 +08:00
web_search_provider.go refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
web_search_provider_credentials.go refactor(credentials): introduce /credentials subresource pattern 2026-05-17 15:27:52 +08:00
wechat_qrcode.go docs(api): add and fix swag annotations on handlers 2026-05-12 13:16:58 +08:00
weknoracloud.go docs(api): add and fix swag annotations on handlers 2026-05-12 13:16:58 +08:00
wiki_page.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00