HKUDS/DeepTutor · error · ValueError
IMA accepts at most {MAX_DETAIL_IDS} knowledge base IDs per
Error message
IMA accepts at most {MAX_DETAIL_IDS} knowledge base IDs per request. What it means
ValueError from IMA client get_knowledge_bases: after normalization/dedup, more than MAX_DETAIL_IDS (20) knowledge base IDs were passed to the detail lookup, exceeding the endpoint's per-request ID cap.
Source
Thrown at deeptutor/services/rag/pipelines/ima/client.py:310
}
)
return {
"knowledge_bases": knowledge_bases,
"next_cursor": cursor_state.next_cursor,
"is_end": cursor_state.is_end,
}
async def get_knowledge_bases(self, ids: list[str]) -> dict[str, dict[str, Any]]:
"""Return details for at most :data:`MAX_DETAIL_IDS` knowledge base ids."""
normalized: list[str] = []
for item in ids:
kb_id = str(item or "").strip()
if kb_id and kb_id not in normalized:
normalized.append(kb_id)
if not normalized:
return {}
if len(normalized) > MAX_DETAIL_IDS:
raise ValueError(
f"IMA accepts at most {MAX_DETAIL_IDS} knowledge base IDs per request."
)
data = await self._wire.post("get_knowledge_base", {"ids": normalized})
infos = data.get("infos")
if not isinstance(infos, dict):
return {}
return {str(kb_id): info for kb_id, info in infos.items() if isinstance(info, dict)}
async def get_knowledge_base(self) -> dict[str, Any]:
"""Return the bound knowledge base's info, or ``{}`` when unknown.
Doubles as the credential check: bad credentials raise
:class:`ImaAuthError`, while a well-formed but unknown id simply yields
no entry for it.
"""
kb_id = self._config.knowledge_base_id
return (await self.get_knowledge_bases([kb_id])).get(kb_id, {})View on GitHub (pinned to 3e82f13042)
Solutions
- Batch IDs into groups of ≤20 and merge the returned info dicts.
- Request only the specific KBs you need to display.
- Cache detail lookups to avoid re-fetching wide ID sets.
Example fix
# before
infos = await client.get_knowledge_bases(all_ids) # 50 ids
# after
infos = {}
for chunk in batched(all_ids, 20):
infos.update(await client.get_knowledge_bases(list(chunk))) Defensive patterns
Strategy: validation
Validate before calling
normalized = dedupe(kb_ids)
if len(normalized) > MAX_DETAIL_IDS:
normalized = normalized[:MAX_DETAIL_IDS] # or batch Prevention
- Wrap get_knowledge_bases in a batching helper capped at 20 IDs.
- Prefer targeted lookups over wide ID lists.
When it happens
Trigger: Calling get_knowledge_bases with >20 IDs directly, or via search_knowledge_bases / get_knowledge_base when the search result set resolves to more than 20 IDs.
Common situations: Listing a large tenant with many KBs and then fetching details for all of them; pagination logic that assumes unbounded ID lookups.
Related errors
- IMA accepts at most {MAX_IMPORT_URLS} URLs per call.
- At least one URL is required.
- Client ID and API key are required.
- OpenAI-compatible embedding model '{model}' does not support
- openai_sdk adapter does not support multimodal `contents`. P
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/0ac0ed73c770cfbc.
Report an issue: GitHub.