{"record":{"id":"066449a87064835f","repo":"langflow-ai/langflow","slug":"job-not-found-exc-s-066449","errorCode":null,"errorMessage":"Job not found: {exc!s}","messagePattern":"Job not found: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"src/backend/base/langflow/api/v1/chat.py","lineNumber":418,"sourceCode":"    try:\n        # Cancel the flow build and check if it was successful\n        cancellation_success = await cancel_flow_build(job_id=job_id, queue_service=queue_service)\n\n        if cancellation_success:\n            # Cancellation succeeded or wasn't needed\n            return CancelFlowResponse(success=True, message=\"Flow build cancelled successfully\")\n        # Cancellation was attempted but failed\n        return CancelFlowResponse(success=False, message=\"Failed to cancel flow build\")\n    except asyncio.CancelledError:\n        # If CancelledError reaches here, it means the task was not successfully cancelled\n        await logger.aerror(f\"Failed to cancel flow build for job_id {job_id} (CancelledError caught)\")\n        return CancelFlowResponse(success=False, message=\"Failed to cancel flow build\")\n    except ValueError as exc:\n        # Job not found\n        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc\n    except JobQueueNotFoundError as exc:\n        await logger.aerror(f\"Job not found: {job_id}. Error: {exc!s}\")\n        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f\"Job not found: {exc!s}\") from exc\n    except Exception as exc:\n        # Any other unexpected error\n        await logger.aexception(f\"Error cancelling flow build for job_id {job_id}: {exc}\")\n        raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(exc)) from exc\n\n\n@router.post(\"/build/{flow_id}/vertices/{vertex_id}\", deprecated=True, include_in_schema=False)\nasync def build_vertex(\n    *,\n    flow_id: uuid.UUID,\n    vertex_id: str,\n    background_tasks: BackgroundTasks,\n    inputs: Annotated[InputValueRequest | None, Body(embed=True)] = None,\n    files: list[str] | None = None,\n    current_user: CurrentActiveUser,\n) -> VertexBuildResponse:\n    \"\"\"Build a vertex instead of the entire graph.\n","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/chat.py#L400-L436","documentation":"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}'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the job_id is exactly the one returned by the build response (`job_id` field).","Ensure all workers share the same queue backend: configure Redis (LANGFLOW_REDIS_HOST etc.) so job state is global, not per-process.","Check Redis maxmemory/eviction policy; job keys should not be evicted prematurely.","Treat the 404 as terminal for that job — re-run the build instead of retrying the cancel."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Confirm the job exists in the queue backend before cancelling\nevents = await client.get(f\"/api/v1/chat/build/{job_id}/events\")\nif events.status_code == 404:\n    # job unknown to backend; do not attempt cancel\n    skip_cancel()","typeGuard":null,"tryCatchPattern":"try:\n    await client.post(cancel_url)\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 404 and \"Job not found\" in e.response.json()[\"detail\"]:\n        return  # job already gone; nothing to cancel\n    raise","preventionTips":["Store job_id immediately from the build response and cancel within the job's TTL.","Run all workers against the same Redis queue backend so job ids are globally visible.","Never fabricate job ids; only use ids returned by the API."],"tags":["langflow","job-queue","http-404","redis"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}