HKUDS/DeepTutor · error · ValueError
IMA Client ID and API Key must be given together.
Error message
IMA Client ID and API Key must be given together.
What it means
Credential-pair invariant in register_ima_kb: only one of client_id/api_key was supplied. IMA auth needs both halves (or neither, to fall back to the account-level pair), so a half-filled pair is rejected.
Solutions
- Supply both client_id and api_key, or leave both empty to use account credentials
- Store the account-level pair in engine settings for shared use
- Validate the pair with the probe helper before registering
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/knowledge/manager.py:1001 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/8f5836fd584e6383.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/knowledge/manager.py:1001
library id the ``ima`` provider queries over IMA's OpenAPI. IMA owns
indexing entirely.
Credentials are optional here: leave them empty and the KB retrieves
with the account-level pair from the engine settings, so rotating that
key updates every such KB at once. Passing a pair pins this KB to it —
the way to reach a second IMA account. Callers should validate the
binding with the probe helper first; this only guards basic invariants.
Raises ``ValueError`` on a missing field, a half-filled credential pair,
or a name clash.
"""
name = (name or "").strip()
client_id = (client_id or "").strip()
api_key = (api_key or "").strip()
knowledge_base_id = (knowledge_base_id or "").strip()
if not name:
raise ValueError("Knowledge base name is required.")
if bool(client_id) != bool(api_key):
raise ValueError("IMA Client ID and API Key must be given together.")
if not knowledge_base_id:
raise ValueError("IMA knowledge base ID is required.")
self.config = self._load_config()
knowledge_bases = self.config.setdefault("knowledge_bases", {})
if name in knowledge_bases:
raise ValueError(f"A knowledge base named '{name}' already exists.")
now = datetime.now().isoformat()
entry: dict[str, Any] = {
"path": name,
"type": IMA_KB_TYPE,
"rag_provider": IMA_PROVIDER,
# Written only when this KB overrides the account credentials;
# absent means "resolve them from the engine settings".
**({"client_id": client_id, "api_key": api_key} if client_id else {}),
"knowledge_base_id": knowledge_base_id,
"description": description or f"Tencent IMA: {name}",View on GitHub (pinned to 3e82f13042)