langflow-ai/langflow · warning · HTTPException

No ingestion job found for the knowledge base {kb_name}

Error message

No ingestion job found for the knowledge base {kb_name}

What it means

404 from POST /api/v1/knowledge_bases/{kb_name}/cancel. The endpoint resolves the KB's asset id (from metadata, falling back to a DB lookup) and asks job_service.get_latest_jobs_by_asset_ids for the newest ingestion job. If no job exists for that asset id — never ingested, or the asset id resolved differently (e.g. KB created on disk before metadata carried an id) — you get this 404.

Source

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

    _assert_kb_not_memory_base(kb_name, _kb_guard.owner_user)
    try:
        kb_path = _resolve_kb_path(kb_name, _kb_guard.owner_user)

        # ``asset_id`` is now sourced from ``KnowledgeBaseRecord.id``
        # (the indexed column on ``job.asset_id``); legacy KBs that
        # only exist on disk fall back to ``metadata['id']``.
        metadata = KBAnalysisHelper.get_metadata(kb_path, fast=True)
        asset_id = await _resolve_kb_asset_id(
            kb_name=kb_name,
            current_user=current_user,
            metadata=metadata,
        )

        # Fetch the latest ingestion job for this KB
        latest_jobs = await job_service.get_latest_jobs_by_asset_ids([asset_id])

        if asset_id not in latest_jobs:
            raise HTTPException(status_code=404, detail=f"No ingestion job found for the knowledge base {kb_name}")

        job = latest_jobs[asset_id]
        job_status = job.status.value if hasattr(job.status, "value") else str(job.status)

        # Check if job is already completed or failed
        if job_status in ["completed", "failed", "cancelled", "timed_out"]:
            raise HTTPException(status_code=400, detail=f"Cannot cancel job with status '{job_status}'")

        revoked = await task_service.revoke_task(job.job_id)
        # Update status immediately so background task can see it
        await job_service.update_job_status(job.job_id, JobStatus.CANCELLED)

        # Clean up any partially ingested chunks from this job. Forward
        # the KB's configured backend + user_id so non-Chroma KBs
        # (Mongo/Astra/Postgres) actually find their variable-backed
        # credentials and delete against the right store — otherwise
        # cleanup silently falls back to Chroma and remote chunks
        # written before the cancel stick around.

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Confirm an ingestion is actually running: check GET /{kb_name}/runs or the job list for that KB
  2. If the job store is in-memory, restarts clear it — the ingestion is not cancellable; let it finish or restart the server
  3. Verify the KB metadata id matches what the job was created with (KBAnalysisHelper.get_metadata)
Defensive patterns

Strategy: validation

Validate before calling

runs = await client.get(f"/api/v1/knowledge_bases/{kb_name}/runs")
has_activity = len(runs.json()["results"]) > 0
if not has_activity:
    skip_cancel()  # nothing to cancel; avoid the 404

Try / catch

try:
    await client.post(f"/api/v1/knowledge_bases/{kb_name}/cancel")
except httpx.HTTPStatusError as e:
    if e.response.status_code == 404:
        return  # no live job — treat as already idle
    raise

Prevention

When it happens

Trigger: Cancelling a KB that has never had an ingestion job; cancelling right after the job record expired or was cleared; KB restored/moved so metadata['id'] no longer matches the job's asset id.

Common situations: UI shows a spinning ingestion for a KB whose job was created before a server restart wiped the job store (non-persistent job backend); user clicks Cancel on a fresh KB with no ingestion yet; asset-id mismatch after KB rename/copy.

Related errors


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