{"record":{"id":"eb8d502173ecd61e","repo":"langgenius/dify","slug":"conversation-not-exists-eb8d50","errorCode":null,"errorMessage":"Conversation Not Exists.","messagePattern":"Conversation Not Exists\\.","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/explore/completion.py","lineNumber":127,"sourceCode":"        args[\"auto_generate_name\"] = False\n\n        installed_app.last_used_at = naive_utc_now()\n        db.session.commit()\n\n        try:\n            response = AppGenerateService.generate(\n                session=session,\n                app_model=app_model,\n                user=current_user,\n                args=args,\n                invoke_from=InvokeFrom.EXPLORE,\n                streaming=streaming,\n            )\n\n            # response-contract:ignore compact_generate_response\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 services.errors.app_model_config.AppModelConfigBrokenError:\n            logger.exception(\"App model config broken.\")\n            raise AppUnavailableError()\n        except ProviderTokenNotInitError as ex:\n            raise ProviderNotInitializeError(ex.description)\n        except QuotaExceededError:\n            raise ProviderQuotaExceededError()\n        except ModelCurrentlyNotSupportError:\n            raise ProviderModelCurrentlyNotSupportError()\n        except InvokeError as e:\n            raise CompletionRequestError(e.description)\n        except ValueError as e:\n            raise e\n        except Exception:\n            logger.exception(\"internal server error.\")\n            raise InternalServerError()","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/explore/completion.py#L109-L145","documentation":"Raised by CompletionApi.post as a werkzeug NotFound (HTTP 404) when AppGenerateService.generate raises services.errors.conversation.ConversationNotExistsError. For completion (text-generation) apps this is rare because CompletionMessageExplorePayload carries no conversation_id, but the shared generate service can still reference a conversation in edge cases (e.g., a persisted query referencing a stale conversation). The controller translates the service-layer error into a 404.","triggerScenarios":"POST /console/installed-apps/<id>/completion-messages where the underlying generation service resolves a conversation_id (passed via args or referenced in app config) that does not exist for this app/user. Also reachable if a completion app was misconfigured to reference a conversation.","commonSituations":"Client reuses stale args from a previous chat session on a completion app; app config references a deleted conversation; data import/migration left dangling conversation references; a buggy client sends an extra conversation_id field.","solutions":["Omit any conversation_id from the request payload for completion apps — completion apps are single-turn.","Start a fresh completion request without carrying over state from a chat session.","If the app config embeds a conversation reference, re-publish the app in Studio.","Verify the installed app is genuinely a completion app and not a mislabeled chat app."],"exampleFix":"// before: forwarding chat state into a completion call\nconst payload = { inputs, query, conversation_id: lastConversationId }\nawait post('/completion-messages', payload)\n\n// after: completion apps are stateless — drop the conversation id\nconst payload = { inputs, query }\nawait post('/completion-messages', payload)","handlingStrategy":"validation","validationCode":"// Completion apps are single-turn: strip any conversation_id before posting.\nfunction buildCompletionPayload({ inputs, query, files }) {\n  // intentionally omit conversation_id\n  return { inputs, query, files };\n}","typeGuard":"function isStatelessCompletionPayload(payload) {\n  return !('conversation_id' in payload) || payload.conversation_id == null;\n}","tryCatchPattern":"try {\n  await postCompletion(id, payload);\n} catch (err) {\n  if (err.status === 404 && /conversation not exists/i.test(err.message)) {\n    // drop any conversation reference and retry once\n    const { conversation_id, ...rest } = payload;\n    await postCompletion(id, rest);\n  } else { throw err; }\n}","preventionTips":["Never forward chat conversation ids into completion-app requests.","Keep completion and chat payload builders separate in client code.","Treat a 404 'Conversation Not Exists' on a completion app as a client payload bug."],"tags":["explore","completion","conversation","not-found","state-management"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}