{"record":{"id":"9589e8bfb0e72c7e","repo":"langflow-ai/langflow","slug":"error-cancelling-ingestion","errorCode":null,"errorMessage":"Error cancelling ingestion.","messagePattern":"Error cancelling ingestion\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"src/backend/base/langflow/api/v1/knowledge_bases.py","lineNumber":2337,"sourceCode":"            job.job_id,\n            kb_path,\n            kb_name,\n            backend_type=backend_type_value,\n            backend_config=backend_config,\n            user_id=current_user.id,\n        )\n\n        if revoked:\n            message = f\"Ingestion job for {job.job_id} cancelled successfully.\"\n        else:\n            message = f\"Job {job.job_id} is already cancelled.\"\n    except asyncio.CancelledError:\n        raise\n    except HTTPException:\n        raise\n    except Exception as e:\n        await logger.aerror(\"Error cancelling ingestion: %s\", e)\n        raise HTTPException(status_code=500, detail=\"Error cancelling ingestion.\") from e\n    else:\n        return {\"message\": message}\n","sourceCodeStart":2319,"sourceCodeEnd":2340,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/knowledge_bases.py#L2319-L2340","documentation":"Catch-all 500 from POST /api/v1/knowledge_bases/{kb_name}/cancel. Exceptions raised during task revocation, job-status update, or partial-chunk cleanup (the endpoint forwards the KB backend + user_id so remote stores clean up correctly) are logged as 'Error cancelling ingestion: <e>' and become this 500. asyncio.CancelledError and HTTPExceptions are re-raised untouched, so this is genuinely unexpected infrastructure failure.","triggerScenarios":"task_service.revoke_task failing (broker down), job_service.update_job_status hitting a DB error, or chunk cleanup failing against a remote vector store (Mongo/Astra/Postgres) with a non-HTTP exception.","commonSituations":"Redis/task broker unavailable; remote vector-store credentials rotated so cleanup cannot connect; DB locked by a concurrent ingestion write.","solutions":["Check server log 'Error cancelling ingestion: ...' for the chained cause","Verify the task broker (Redis) is reachable — revoke_task needs it","Check remote vector-store credentials/variables for the KB are still valid","Retry the cancel; note the job may already be marked CANCELLED if the failure happened after update_job_status"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await client.post(f\"/api/v1/knowledge_bases/{kb_name}/cancel\")\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 500:\n        # job may already be CANCELLED — re-check state before retrying\n        state = await get_latest_run_status(client, kb_name)\n        if state == \"cancelled\":\n            return\n    raise","preventionTips":["Verify the task broker (Redis) is healthy before issuing cancels","Keep remote KB vector-store credential variables valid so cleanup cannot throw","Re-read job status after a failed cancel — the status update may have landed before the error"],"tags":["knowledge-base","cancel","http-500","catch-all","langflow"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}