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
fix(rest-api): address all PR #150 review feedback (#150)
Must-fix (correctness/data):
- Serialize same-KB mutations with an asyncio.Lock before kb_ingest_lock.
The ingest lock tracks reentrancy in threading.local, but the event loop
runs every request on one thread, so concurrent same-KB requests were
mis-counted as re-entrant and bypassed mutual exclusion. [init/lint --fix/recompile]
- Watcher stop() now joins the worker before clearing state and leaves a
draining marker, so a restart can no longer orphan an in-flight compile
and double-ingest raw/. [watch_service.py]
- Extract a shared save_exploration() used by both CLI and REST: strips
ghost wikilinks, generates a CJK-safe slug (hash fallback), uniquifies
on collision, and escapes the question for YAML frontmatter. [cli.py]
Should-fix:
- Cap /watch/events SSE with a default timeout and an is_disconnected check.
- Abort the in-flight SSE on component unmount / KB switch (AbortController).
- Force allow_credentials off when CORS origins is a wildcard.
- Constant-time token compare (hmac.compare_digest); the SPA warns when the
configured API base is cross-origin and non-HTTPS.
- Isolate per-KB LLM credentials via LlmCredentialBundle (dotenv_values, no
os.environ pollution; a per-request LitellmModel instance).
Regression (introduced by the per-KB bundle isolation above):
- build_run_config_from_bundle passed model=f"litellm/{model}" to LitellmModel,
but LitellmModel feeds model verbatim to litellm.acompletion, so the prefix
produced "litellm/openai/deepseek-v4-flash" and litellm rejected it as an
unknown provider. CLI was unaffected (bundle=None); all REST query/chat failed.
Refactor/cleanup:
- Extract _is_kb_dir; move _setup_llm_key to cli; model_dump() (pydantic v2).
- Drop the hand-maintained openkb-postman.json (OpenAPI is served at /docs).
- Slim README to short subsections + links; move the REST reference and
Workbench tour to examples/rest-api/README.md.
Frontend:
- Default the UI to English with a zh/en toggle (i18n.jsx).
- index.html lang/title default to English.
Tests: 118 passed (query/api/api_watch/watch_service/per_request_overrides/save_exploration).
0 commit comments