{"record":{"id":"c2f48cb49e697550","repo":"langgenius/dify","slug":"trace-config-not-exist","errorCode":"trace_config_not_exist","errorMessage":"Trace config not exist.","messagePattern":"Trace config not exist\\.","errorType":"error_code","errorClass":"TracingConfigNotExist","httpStatus":400,"severity":"warning","filePath":"api/controllers/console/app/ops_trace.py","lineNumber":152,"sourceCode":"    @console_ns.response(403, \"Insufficient permissions\")\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_TRACING_CONFIG)\n    @get_app_model\n    @model_validate(TraceConfigPayload)\n    def patch(self, req_data: TraceConfigPayload, app_model: App):\n        \"\"\"Update an existing trace app configuration\"\"\"\n        try:\n            result = OpsService.update_tracing_app_config(\n                app_id=app_model.id,\n                tracing_provider=req_data.tracing_provider,\n                tracing_config=req_data.tracing_config,\n                session=db.session(),\n            )\n            if not result:\n                raise TracingConfigNotExist()\n            return {\"result\": \"success\"}\n        except Exception as e:\n            raise BadRequest(str(e))\n\n    @console_ns.doc(\"delete_trace_app_config\")\n    @console_ns.doc(description=\"Delete an existing tracing configuration for an application\")\n    @console_ns.doc(params={\"app_id\": \"Application ID\"})\n    @console_ns.doc(params=query_params_from_model(TraceProviderQuery))\n    @console_ns.response(204, \"Tracing configuration deleted successfully\")\n    @console_ns.response(400, \"Invalid request parameters or configuration not found\")\n    @console_ns.response(403, \"Insufficient permissions\")\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_TRACING_CONFIG)\n    @get_app_model\n    @model_validate(TraceProviderQuery)","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/ops_trace.py#L134-L170","documentation":"Raised as TracingConfigNotExist in PATCH /apps/{app_id}/ops-trace when OpsService.update_tracing_app_config returns a falsy result (api/controllers/console/app/ops_trace.py:151-152). The service returns falsy when no existing tracing config for the given app+provider is found to update. The outer handler surfaces it as BadRequest(400) with message 'Trace config not exist.'","triggerScenarios":"PATCHing a trace config for an app+provider that has no stored config — update-before-create. The endpoint requires the config to already exist.","commonSituations":"Front-end calling PATCH on first save instead of POST; config was deleted between load and save; provider mismatch between the loaded config and the PATCH payload; race with another admin deleting the config.","solutions":["POST the config first to create it, then PATCH for subsequent updates.","If the config was deleted, recreate via POST.","Ensure the tracing_provider in the PATCH payload matches an existing stored config.","Refresh the trace-config view before editing to confirm it still exists."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure a config exists before PATCHing\nconst existing = await fetch(`/apps/${appId}/ops-trace?provider=${provider}`).then(r=>r.ok?r.json():null)\nif (!existing) await createTraceConfig(appId, payload)\nelse await patchTraceConfig(appId, payload)","typeGuard":null,"tryCatchPattern":"try {\n  await patchTraceConfig(appId, payload)\n} catch (e) {\n  if (e.code === 'trace_config_not_exist') return createTraceConfig(appId, payload)\n  throw e\n}","preventionTips":["Refresh the trace-config view before editing.","Choose POST/PATCH based on current existence, not assumption."],"tags":["ops-trace","tracing-config","not-exist","api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}