{"record":{"id":"ba526b10196ccb3c","repo":"langgenius/dify","slug":"conversation-not-exists-ba526b","errorCode":null,"errorMessage":"Conversation Not Exists.","messagePattern":"Conversation Not Exists\\.","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py","lineNumber":292,"sourceCode":"    @with_current_user\n    @get_rag_pipeline\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)\n    @model_validate(NodeRunPayload)\n    def post(self, req_data: NodeRunPayload, current_user: Account, pipeline: Pipeline, node_id: str):\n        \"\"\"\n        Run draft workflow iteration node\n        \"\"\"\n        args = req_data.model_dump(exclude_none=True)\n\n        try:\n            response = PipelineGenerateService.generate_single_iteration(\n                pipeline=pipeline, user=current_user, node_id=node_id, args=args, session=db.session(), streaming=True\n            )\n\n            return helper.compact_generate_response(response)\n        except services.errors.conversation.ConversationNotExistsError:\n            raise NotFound(\"Conversation Not Exists.\")\n        except services.errors.conversation.ConversationCompletedError:\n            raise ConversationCompletedError()\n        except ValueError as e:\n            raise e\n        except Exception:\n            logging.exception(\"internal server error.\")\n            raise InternalServerError()\n\n\n@console_ns.route(\"/rag/pipelines/<uuid:pipeline_id>/workflows/draft/loop/nodes/<string:node_id>/run\")\nclass RagPipelineDraftRunLoopNodeApi(Resource):\n    @console_ns.expect(console_ns.models[NodeRunPayload.__name__])\n    @console_ns.response(200, \"Success\", console_ns.models[RagPipelineOpaqueResponse.__name__])\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py#L274-L310","documentation":"Returned (HTTP 404, plain `NotFound`) by POST /rag/pipelines/<pipeline_id>/workflows/draft/iteration/nodes/<node_id>/run when the underlying service raises `services.errors.conversation.ConversationNotExistsError`. Iteration node runs operate within a conversation context; if the referenced conversation id is absent (deleted, never created, expired), the run cannot proceed. The controller re-raises as werkzeug NotFound, so the response is a generic 404 with this message.","triggerScenarios":"Running an iteration node with a `conversation_id` that was deleted, belongs to another app, or was never created; replaying a request after the conversation was cleared; race with conversation expiration.","commonSituations":"Frontend caching a conversation_id across sessions. Test runs against ephemeral conversations that have been swept. Long-lived debugger sessions referencing a conversation that timed out.","solutions":["Start a fresh conversation/run context before invoking the iteration node.","Validate that the conversation still exists via the conversation API before retrying.","Clear cached conversation ids on logout/session expiry.","Surfaces a 'conversation expired, start new' prompt to the user."],"exampleFix":"// before\nawait post(`${base}/draft/iteration/nodes/${nodeId}/run`, { inputs, conversation_id: staleId })\n// after\nconst conv = await ensureConversation() // creates one if absent\nawait post(`${base}/draft/iteration/nodes/${nodeId}/run`, { inputs, conversation_id: conv.id })","handlingStrategy":"try-catch","validationCode":"if (!conversationId || !(await conversationExists(conversationId))) {\n  conversationId = (await createConversation()).id\n}\nawait post(`${base}/draft/iteration/nodes/${nodeId}/run`, { inputs, conversation_id: conversationId })","typeGuard":null,"tryCatchPattern":"try {\n  await post(`${base}/draft/iteration/nodes/${nodeId}/run`, payload)\n} catch (e) {\n  if (e.status === 404 && /Conversation Not Exists/.test(e.message)) {\n    // create a conversation and retry once\n  } else throw e\n}","preventionTips":["Validate conversation existence before invoking iteration runs.","Clear cached conversation ids on session expiry.","Surface a 'start new conversation' prompt when 404 is returned."],"tags":["rag-pipeline","iteration","conversation","not-found","api","rest"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}