langgenius/dify · warning · TracingConfigNotExist

trace_config_not_exist

trace_config_not_exist

Error message

Trace config not exist.

What it means

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.'

Source

Thrown at api/controllers/console/app/ops_trace.py:152

    @console_ns.response(403, "Insufficient permissions")
    @setup_required
    @login_required
    @account_initialization_required
    @edit_permission_required
    @rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_TRACING_CONFIG)
    @get_app_model
    @model_validate(TraceConfigPayload)
    def patch(self, req_data: TraceConfigPayload, app_model: App):
        """Update an existing trace app configuration"""
        try:
            result = OpsService.update_tracing_app_config(
                app_id=app_model.id,
                tracing_provider=req_data.tracing_provider,
                tracing_config=req_data.tracing_config,
                session=db.session(),
            )
            if not result:
                raise TracingConfigNotExist()
            return {"result": "success"}
        except Exception as e:
            raise BadRequest(str(e))

    @console_ns.doc("delete_trace_app_config")
    @console_ns.doc(description="Delete an existing tracing configuration for an application")
    @console_ns.doc(params={"app_id": "Application ID"})
    @console_ns.doc(params=query_params_from_model(TraceProviderQuery))
    @console_ns.response(204, "Tracing configuration deleted successfully")
    @console_ns.response(400, "Invalid request parameters or configuration not found")
    @console_ns.response(403, "Insufficient permissions")
    @setup_required
    @login_required
    @account_initialization_required
    @edit_permission_required
    @rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_TRACING_CONFIG)
    @get_app_model
    @model_validate(TraceProviderQuery)

View on GitHub (pinned to ef8544b173)

Solutions

  1. POST the config first to create it, then PATCH for subsequent updates.
  2. If the config was deleted, recreate via POST.
  3. Ensure the tracing_provider in the PATCH payload matches an existing stored config.
  4. Refresh the trace-config view before editing to confirm it still exists.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure a config exists before PATCHing
const existing = await fetch(`/apps/${appId}/ops-trace?provider=${provider}`).then(r=>r.ok?r.json():null)
if (!existing) await createTraceConfig(appId, payload)
else await patchTraceConfig(appId, payload)

Try / catch

try {
  await patchTraceConfig(appId, payload)
} catch (e) {
  if (e.code === 'trace_config_not_exist') return createTraceConfig(appId, payload)
  throw e
}

Prevention

When it happens

Trigger: PATCHing a trace config for an app+provider that has no stored config — update-before-create. The endpoint requires the config to already exist.

Common situations: 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.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/c2f48cb49e697550. Report an issue: GitHub.