langflow-ai/langflow · warning · HTTPException

Job not found: {exc!s}

Error message

Job not found: {exc!s}

What it means

Raised as HTTP 404 when cancelling a flow build whose job_id is not present in the job queue backend. JobQueueNotFoundError comes from the queue service layer (get_job_info/persistence) and means the id is unknown to the shared backend — expired, evicted, never started on this backend, or from a different deployment. The detail echoes the underlying message: 'Job not found: {exc!s}'.

Source

Thrown at src/backend/base/langflow/api/v1/chat.py:418

    try:
        # Cancel the flow build and check if it was successful
        cancellation_success = await cancel_flow_build(job_id=job_id, queue_service=queue_service)

        if cancellation_success:
            # Cancellation succeeded or wasn't needed
            return CancelFlowResponse(success=True, message="Flow build cancelled successfully")
        # Cancellation was attempted but failed
        return CancelFlowResponse(success=False, message="Failed to cancel flow build")
    except asyncio.CancelledError:
        # If CancelledError reaches here, it means the task was not successfully cancelled
        await logger.aerror(f"Failed to cancel flow build for job_id {job_id} (CancelledError caught)")
        return CancelFlowResponse(success=False, message="Failed to cancel flow build")
    except ValueError as exc:
        # Job not found
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
    except JobQueueNotFoundError as exc:
        await logger.aerror(f"Job not found: {job_id}. Error: {exc!s}")
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Job not found: {exc!s}") from exc
    except Exception as exc:
        # Any other unexpected error
        await logger.aexception(f"Error cancelling flow build for job_id {job_id}: {exc}")
        raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(exc)) from exc


@router.post("/build/{flow_id}/vertices/{vertex_id}", deprecated=True, include_in_schema=False)
async def build_vertex(
    *,
    flow_id: uuid.UUID,
    vertex_id: str,
    background_tasks: BackgroundTasks,
    inputs: Annotated[InputValueRequest | None, Body(embed=True)] = None,
    files: list[str] | None = None,
    current_user: CurrentActiveUser,
) -> VertexBuildResponse:
    """Build a vertex instead of the entire graph.

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Confirm the job_id is exactly the one returned by the build response (`job_id` field).
  2. Ensure all workers share the same queue backend: configure Redis (LANGFLOW_REDIS_HOST etc.) so job state is global, not per-process.
  3. Check Redis maxmemory/eviction policy; job keys should not be evicted prematurely.
  4. Treat the 404 as terminal for that job — re-run the build instead of retrying the cancel.
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the job exists in the queue backend before cancelling
events = await client.get(f"/api/v1/chat/build/{job_id}/events")
if events.status_code == 404:
    # job unknown to backend; do not attempt cancel
    skip_cancel()

Try / catch

try:
    await client.post(cancel_url)
except httpx.HTTPStatusError as e:
    if e.response.status_code == 404 and "Job not found" in e.response.json()["detail"]:
        return  # job already gone; nothing to cancel
    raise

Prevention

When it happens

Trigger: POST cancel with a job_id that was never registered (typo/guessed id), a job whose TTL expired after completion, a job created on an in-memory queue but cancelled through a different worker, or Redis eviction flushing the job key.

Common situations: Multi-worker deployments where some workers run the in-memory queue instead of Redis; long-lived job ids reused after expiry; client retaining a stale job_id across a server restart.

Related errors


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