{"record":{"id":"8f5836fd584e6383","repo":"HKUDS/DeepTutor","slug":"ima-client-id-and-api-key-must-be-given-together","errorCode":null,"errorMessage":"IMA Client ID and API Key must be given together.","messagePattern":"IMA Client ID and API Key must be given together\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/knowledge/manager.py","lineNumber":1001,"sourceCode":"        library id the ``ima`` provider queries over IMA's OpenAPI. IMA owns\n        indexing entirely.\n\n        Credentials are optional here: leave them empty and the KB retrieves\n        with the account-level pair from the engine settings, so rotating that\n        key updates every such KB at once. Passing a pair pins this KB to it —\n        the way to reach a second IMA account. Callers should validate the\n        binding with the probe helper first; this only guards basic invariants.\n        Raises ``ValueError`` on a missing field, a half-filled credential pair,\n        or a name clash.\n        \"\"\"\n        name = (name or \"\").strip()\n        client_id = (client_id or \"\").strip()\n        api_key = (api_key or \"\").strip()\n        knowledge_base_id = (knowledge_base_id or \"\").strip()\n        if not name:\n            raise ValueError(\"Knowledge base name is required.\")\n        if bool(client_id) != bool(api_key):\n            raise ValueError(\"IMA Client ID and API Key must be given together.\")\n        if not knowledge_base_id:\n            raise ValueError(\"IMA knowledge base ID is required.\")\n\n        self.config = self._load_config()\n        knowledge_bases = self.config.setdefault(\"knowledge_bases\", {})\n        if name in knowledge_bases:\n            raise ValueError(f\"A knowledge base named '{name}' already exists.\")\n\n        now = datetime.now().isoformat()\n        entry: dict[str, Any] = {\n            \"path\": name,\n            \"type\": IMA_KB_TYPE,\n            \"rag_provider\": IMA_PROVIDER,\n            # Written only when this KB overrides the account credentials;\n            # absent means \"resolve them from the engine settings\".\n            **({\"client_id\": client_id, \"api_key\": api_key} if client_id else {}),\n            \"knowledge_base_id\": knowledge_base_id,\n            \"description\": description or f\"Tencent IMA: {name}\",","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/knowledge/manager.py#L983-L1019","documentation":"Error \"IMA Client ID and API Key must be given together.\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/knowledge/manager.py:1001 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}