{"record":{"id":"7af87574245a1555","repo":"langgenius/dify","slug":"not-completion-app-7af875","errorCode":"not_completion_app","errorMessage":"Not Completion App","messagePattern":"Not Completion App","errorType":"error_code","errorClass":"NotCompletionAppError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/explore/message.py","lineNumber":161,"sourceCode":"\n        return ResultResponse(result=\"success\").model_dump(mode=\"json\")\n\n\n@console_ns.route(\n    \"/installed-apps/<uuid:installed_app_id>/messages/<uuid:message_id>/more-like-this\",\n    endpoint=\"installed_app_more_like_this\",\n)\nclass MessageMoreLikeThisApi(InstalledAppResource):\n    @console_ns.doc(params=query_params_from_model(MoreLikeThisQuery))\n    @console_ns.response(200, \"Success\")\n    @with_current_user\n    @with_session\n    def get(self, session: Session, current_user: Account, installed_app: InstalledApp, message_id: UUID):\n        app_model = installed_app.app_with_session(session=session)\n        if app_model is None:\n            raise AppUnavailableError()\n        if app_model.mode != \"completion\":\n            raise NotCompletionAppError()\n\n        message_id_str = str(message_id)\n\n        args = MoreLikeThisQuery.model_validate(request.args.to_dict())\n\n        streaming = args.response_mode == \"streaming\"\n\n        try:\n            response = AppGenerateService.generate_more_like_this(\n                session=session,\n                app_model=app_model,\n                user=current_user,\n                message_id=message_id_str,\n                invoke_from=InvokeFrom.EXPLORE,\n                streaming=streaming,\n            )\n            # response-contract:ignore compact_generate_response\n            return helper.compact_generate_response(response)","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/explore/message.py#L143-L179","documentation":"HTTP 400 with error_code not_completion_app, raised by GET more-like-this when app_model.mode != 'completion'. The 'more like this' generation feature is only implemented for legacy completion-mode apps; chat, agent-chat, advanced-chat and workflow apps are rejected.","triggerScenarios":"GET /installed-apps/<id>/messages/<mid>/more-like-this on any app whose mode is not exactly 'completion'. The mode check runs after the app is loaded.","commonSituations":"Calling more-like-this on a chat or workflow app; app migrated from completion to chat; UI surfaces the action for all installed apps regardless of mode.","solutions":["Only show the more-like-this action when app.mode === 'completion'.","Read the mode from GET /installed-apps/<id> (InstalledAppInfoResponse.mode) before calling.","For chat apps, use the suggested-questions endpoint or the normal chat-generation flow instead.","If the app should be completion mode, verify the owner did not change the mode."],"exampleFix":"// before: offer more-like-this for every app\n{messages.map(m => <MoreLikeThisButton appId={id} messageId={m.id} />)}\n\n// after: completion apps only\n{app.mode === 'completion' && messages.map(m => (\n  <MoreLikeThisButton appId={id} messageId={m.id} />\n))}","handlingStrategy":"type-guard","validationCode":"function isCompletionApp(app) { return app?.mode === 'completion'; }\nif (!isCompletionApp(app)) return; // skip more-like-this for non-completion apps","typeGuard":"function isCompletionApp(app) {\n  return Boolean(app) && app.mode === 'completion';\n}","tryCatchPattern":"try {\n  return await get(moreLikeThisUrl(id, mid));\n} catch (e) {\n  if (e.code === 'not_completion_app') { hideMoreLikeThis(id); return null; }\n  throw e;\n}","preventionTips":["Gate more-like-this UI on app.mode === 'completion'.","For chat apps, use suggested-questions instead.","Re-check mode after the owner changes the app."],"tags":["rest-api","explore","app-mode","more-like-this","validation","dify"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}