{"record":{"id":"30b7c9270e910596","repo":"langgenius/dify","slug":"conversation-not-exists-30b7c9","errorCode":null,"errorMessage":"Conversation Not Exists.","messagePattern":"Conversation Not Exists\\.","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/explore/message.py","lineNumber":109,"sourceCode":"                app_model,\n                current_user,\n                args.conversation_id,\n                args.first_id or None,\n                args.limit,\n                session=session,\n            )\n            adapter = TypeAdapter(ExploreMessageListItem)\n            items = [\n                adapter.validate_python(MessageResponseSource(message, session=session), from_attributes=True)\n                for message in pagination.data\n            ]\n            return ExploreMessageInfiniteScrollPagination(\n                limit=pagination.limit,\n                has_more=pagination.has_more,\n                data=items,\n            ).model_dump(mode=\"json\")\n        except ConversationNotExistsError:\n            raise NotFound(\"Conversation Not Exists.\")\n        except FirstMessageNotExistsError:\n            raise NotFound(\"First Message Not Exists.\")\n\n\n@console_ns.route(\n    \"/installed-apps/<uuid:installed_app_id>/messages/<uuid:message_id>/feedbacks\",\n    endpoint=\"installed_app_message_feedback\",\n)\nclass MessageFeedbackApi(InstalledAppResource):\n    @console_ns.expect(console_ns.models[MessageFeedbackPayload.__name__])\n    @console_ns.response(200, \"Feedback submitted successfully\", console_ns.models[ResultResponse.__name__])\n    @with_current_user\n    @model_validate(MessageFeedbackPayload)\n    def post(\n        self, req_data: MessageFeedbackPayload, current_user: Account, installed_app: InstalledApp, message_id: UUID\n    ):\n        app_model = installed_app.app_with_session(session=db.session())\n        if app_model is None:","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/explore/message.py#L91-L127","documentation":"HTTP 404 raised by GET /installed-apps/<id>/messages when MessageService.pagination_by_first_id raises ConversationNotExistsError. The conversation_id query parameter does not resolve to a conversation for this app/user.","triggerScenarios":"GET /installed-apps/<id>/messages?conversation_id=<cid> where <cid> does not exist, was deleted, belongs to a different app, or belongs to a different user. The service-level error is translated to NotFound at the controller boundary.","commonSituations":"Stale conversation_id kept in client state after the conversation was deleted; user switched tenants; conversation id copied from another app; retention job purged old conversations.","solutions":["Treat 404 on this endpoint as 'conversation gone' and reset the client to start a new conversation.","Validate the conversation_id belongs to the current user/app by listing conversations first if available.","Clear cached conversation_id on tenant switch or app re-install.","Confirm the conversation_id is a UUID-format string and not truncated."],"exampleFix":"// before: reuse a conversation id that may be stale\nconst msgs = await get(messagesUrl({ conversation_id: lastConvId }));\n\n// after: reset on 404\ntry {\n  const msgs = await get(messagesUrl({ conversation_id: lastConvId }));\n} catch (e) {\n  if (e.status === 404 && e.code === undefined) { lastConvId = null; startNewConversation(); }\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Validate conversation id format and ownership before paging\nfunction validConversationId(v) {\n  return typeof v === 'string' && /^[0-9a-fA-F-]{36}$/.test(v);\n}\nif (!validConversationId(conversationId)) conversationId = null;","typeGuard":"function isLikelyValidConversationId(value) {\n  return typeof value === 'string' && /^[0-9a-fA-F-]{36}$/.test(value);\n}","tryCatchPattern":"try {\n  return await get(messagesUrl(id, { conversation_id }));\n} catch (e) {\n  if (e.status === 404 && /Conversation Not Exists/.test(e.message)) {\n    clearStoredConversationId();\n    return get(messagesUrl(id, {})); // start fresh\n  }\n  throw e;\n}","preventionTips":["Clear cached conversation_id on tenant switch or app re-install.","Reset to a new conversation when 404 is observed.","Do not persist conversation ids indefinitely; let them expire."],"tags":["rest-api","explore","not-found","conversation","message","dify"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}