langflow-ai/langflow · error · HTTPException

Error listing knowledge bases.

Error message

Error listing knowledge bases.

What it means

Catch-all 500 around the list-knowledge-bases handler: any exception while reading knowledge_base rows, falling back to disk scan, computing sizes, or joining job status is logged ('Error listing knowledge bases: <e>') and returned as this generic detail. Per-KB job-status join errors (ValueError/AttributeError on bad UUIDs) are swallowed; only failures that escape the loop reach this handler.

Source

Thrown at src/backend/base/langflow/api/v1/knowledge_bases.py:1425

            }
            for kb_info in knowledge_bases:
                try:
                    kb_uuid = uuid.UUID(kb_info.id)
                    if kb_uuid in latest_jobs:
                        job = latest_jobs[kb_uuid]
                        raw_status = job.status.value if hasattr(job.status, "value") else str(job.status)
                        mapped = job_status_map.get(raw_status)
                        if mapped:
                            kb_info.status = mapped
                        # For "completed", keep the file-marker / chunk-count status already set
                        kb_info.last_job_id = str(job.job_id)
                except (ValueError, AttributeError):
                    # If KB ID is not a valid UUID, skip job status update
                    pass

    except Exception as e:
        await logger.aerror("Error listing knowledge bases: %s", e)
        raise HTTPException(status_code=500, detail="Error listing knowledge bases.") from e
    else:
        return knowledge_bases


@router.get("/connectors", status_code=HTTPStatus.OK)
async def list_connectors(_current_user: CurrentActiveUser) -> list[ConnectorCatalogEntry]:
    """Enumerate registered connector sources for the UI picker.

    Declared before the ``GET /{kb_name}`` route so FastAPI matches
    the literal ``/connectors`` path first rather than treating it
    as a ``kb_name`` parameter. Skips ``file_upload`` because that
    path is wired through the dedicated upload modal.
    """
    entries: list[ConnectorCatalogEntry] = []
    for source_type in registered_sources():
        if source_type is SourceType.FILE_UPLOAD:
            continue
        try:

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Read the server log line 'Error listing knowledge bases: <e>' to identify the failing layer (DB vs disk).
  2. Confirm the database is up and migrations are applied (make alembic-upgrade).
  3. Fix permissions/existence of the KB storage root used by KBStorageHelper.
  4. Move or repair malformed KB directories that break the disk scan.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    kbs = (await client.get("/api/v1/knowledge_bases")).json()
except HTTPStatusError as e:
    if e.response.status_code == 500:
        show_degraded_ui()  # KB list unavailable; backend log has the cause
        await check_backend_health()

Prevention

When it happens

Trigger: GET /api/v1/knowledge_bases when the database query for KB rows fails, the disk-scan recovery fallback raises (storage misconfiguration), or size/stat calls raise on unreadable directories.

Common situations: Database down or schema not migrated, KB storage root deleted or unreadable by the backend user, or a broken KB directory on disk that the scan fallback cannot stat.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/efae9032e486cc87. Report an issue: GitHub.