langflow-ai/langflow · error · HTTPException
Error getting knowledge base.
Error message
Error getting knowledge base.
What it means
Catch-all 500 from the get-single-KB endpoint: exceptions while resolving the KB path, loading metadata from disk (knowledge_base_service.load_metadata_from_disk), or computing directory size are logged with the kb_name and wrapped. HTTPExceptions (e.g. 404 for a missing KB) pass through unchanged.
Source
Thrown at src/backend/base/langflow/api/v1/knowledge_bases.py:1489
dir_name=record.name,
metadata=knowledge_base_service.record_to_metadata_dict(record),
size=record.size_bytes,
)
kb_path = _resolve_kb_path(kb_name, _kb_guard.owner_user)
metadata = knowledge_base_service.load_metadata_from_disk(kb_path)
return _build_kb_info(
kb_name=kb_name.replace("_", " "),
dir_name=kb_name,
metadata=metadata,
size=KBStorageHelper.get_directory_size(kb_path),
)
except HTTPException:
raise
except Exception as e:
await logger.aerror("Error getting knowledge base '%s': %s", kb_name, e)
raise HTTPException(status_code=500, detail="Error getting knowledge base.") from e
@router.get("/{kb_name}/chunks", status_code=HTTPStatus.OK, dependencies=[Depends(_check_memory_base_association)])
async def get_knowledge_base_chunks(
kb_name: str,
current_user: CurrentActiveUser,
request: Request,
page: Annotated[int, Query(ge=1)] = 1,
limit: Annotated[int, Query(ge=1, le=100)] = 50,
search: Annotated[str, Query(description="Filter chunks whose text contains this substring")] = "",
source_type: Annotated[
str | None,
Query(description="Only return chunks ingested via the given source type (e.g. 'file_upload', 'folder')."),
] = None,
file_name: Annotated[
str | None,
Query(description="Only return chunks whose source filename exactly matches."),
] = None,View on GitHub (pinned to 976ec789d2)
Solutions
- Check server logs for "Error getting knowledge base '<kb>': <e>" to see whether it was metadata parsing or size computation.
- Verify the KB directory on the server is intact and readable.
- If the directory is gone, delete the stale KB record and recreate the KB.
- Restore the metadata file from backup or re-save the KB config via the UI.
Defensive patterns
Strategy: try-catch
Validate before calling
async def kb_gettable(client, kb_name: str) -> bool:
return (await client.get(f"/api/v1/knowledge_bases/{kb_name}")).status_code == 200 Try / catch
try:
resp = await client.get(f"/api/v1/knowledge_bases/{kb_name}")
except HTTPStatusError as e:
if e.response.status_code == 500:
log("KB metadata/size read failed", kb_name) # check server log
elif e.response.status_code == 404:
log("KB not found", kb_name) Prevention
- Do not delete or move KB directories directly on disk; delete via the API.
- Back up KB directories including metadata files.
- Alert on 500s from single-KB reads — they usually mean on-disk corruption.
When it happens
Trigger: GET /api/v1/knowledge_bases/{kb_name} where the KB row exists but metadata loading fails (corrupted/unreadable metadata file) or KBStorageHelper.get_directory_size raises (permission errors, broken symlinks, deleted directory still recorded in DB).
Common situations: KB files deleted or moved behind the backend's back, NFS/permission changes on the storage root, or partially written metadata after a crash.
Related errors
- Error ingesting files to knowledge base.
- Error ingesting folder to knowledge base.
- Error listing knowledge bases.
- Error listing metadata keys.
- Metadata value for '{key}' exceeds {KB_METADATA_MAX_VALUE_LE
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/434d3d7dcde4d118.
Report an issue: GitHub.