HKUDS/DeepTutor · error · ValueError

IMA knowledge base ID is required.

Error message

IMA knowledge base ID is required.

What it means

Basic-shape guard in register_ima_kb: the IMA library id (the knowledge base IMA will query) was not supplied, and without it the KB has nothing to bind to.

Solutions

  1. Provide the IMA knowledge base id from the IMA console
  2. Look up the library id in the IMA account before registering
  3. Copy the id exactly — it is matched verbatim
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at deeptutor/knowledge/manager.py:1003 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/da4f04130cb6ad8d. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/knowledge/manager.py:1003

        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}",
            "status": "ready",
            "needs_reindex": False,

View on GitHub (pinned to 3e82f13042)