{"record":{"id":"7bf9aa0e7f5d7662","repo":"langgenius/dify","slug":"trigger-not-found","errorCode":null,"errorMessage":"Trigger not found","messagePattern":"Trigger not found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/app/workflow_trigger.py","lineNumber":194,"sourceCode":"    @with_current_tenant_id\n    @get_app_model(mode=AppMode.WORKFLOW)\n    @model_validate(ParserEnable)\n    def post(self, req_data: ParserEnable, current_tenant_id: str, app_model: App):\n        \"\"\"Update app trigger (enable/disable)\"\"\"\n\n        trigger_id = req_data.trigger_id\n        with sessionmaker(db.engine, expire_on_commit=False).begin() as session:\n            # Find the trigger using select\n            trigger = session.execute(\n                select(AppTrigger).where(\n                    AppTrigger.id == trigger_id,\n                    AppTrigger.tenant_id == current_tenant_id,\n                    AppTrigger.app_id == app_model.id,\n                )\n            ).scalar_one_or_none()\n\n            if not trigger:\n                raise NotFound(\"Trigger not found\")\n\n            # Update status based on enable_trigger boolean\n            trigger.status = AppTriggerStatus.ENABLED if req_data.enable_trigger else AppTriggerStatus.DISABLED\n\n        # Add computed icon field\n        url_prefix = dify_config.CONSOLE_API_URL + \"/console/api/workspaces/current/tool-provider/builtin/\"\n        if trigger.trigger_type == \"trigger-plugin\":\n            trigger.icon = url_prefix + trigger.provider_name + \"/icon\"  # type: ignore\n        else:\n            trigger.icon = \"\"  # type: ignore\n\n        return dump_response(WorkflowTriggerResponse, trigger)\n","sourceCodeStart":176,"sourceCodeEnd":207,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/workflow_trigger.py#L176-L207","documentation":"Raised by POST /apps/{app_id}/trigger-enable when no AppTrigger row matches (trigger_id, current_tenant_id, app_id). The trigger must belong to the caller's tenant and the URL's app. Returned via flask_restx NotFound (HTTP 404).","triggerScenarios":"POST /console/api/apps/{app_id}/trigger-enable with body {trigger_id, enable_trigger} where trigger_id does not exist, belongs to another tenant, belongs to another app, or was deleted.","commonSituations":"Stale trigger_id in the UI after the trigger was removed; cross-tenant or cross-app reference; enabling a trigger on the wrong app after a copy; trigger row hard-deleted by a cleanup job.","solutions":["Refresh the trigger list via GET /apps/{app_id}/triggers and use a current trigger_id.","Confirm the trigger belongs to the same tenant and app as the URL before toggling.","If the trigger was removed, recreate it through the workflow studio Trigger panel."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const triggers = await get(`/apps/${appId}/triggers`);\nconst ok = triggers.data.some(t => t.id === triggerId);\nif (!ok) { /* do not POST trigger-enable */ }","typeGuard":null,"tryCatchPattern":"try {\n  await post(`/apps/${appId}/trigger-enable`, { trigger_id: triggerId, enable_trigger: val });\n} catch (e) {\n  if (e.code === 404 && /trigger not found/i.test(e.message)) {\n    // refresh trigger list, drop stale id\n  } else { throw e; }\n}","preventionTips":["Refresh the trigger list before toggling to avoid stale ids.","Confirm the trigger is owned by the current tenant and app."],"tags":["api","not-found","workflow","trigger","tenancy"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}