langgenius/dify · error · ValueError
tracing_provider is required when enabled is True
Error message
tracing_provider is required when enabled is True
What it means
Raised by AppTracePayload.validate_tracing_provider (Pydantic field_validator) when enabled is True but tracing_provider is None or empty. AppTracePayload backs the endpoint that toggles app-level tracing integration. Surfaces as a Pydantic ValidationError on the tracing config PUT/POST.
Source
Thrown at api/controllers/console/app/app.py:213
class AppSiteStatusPayload(BaseModel):
enable_site: bool = Field(..., description="Enable or disable site")
class AppApiStatusPayload(BaseModel):
enable_api: bool = Field(..., description="Enable or disable API")
class AppTracePayload(BaseModel):
enabled: bool = Field(..., description="Enable or disable tracing")
tracing_provider: str | None = Field(default=None, description="Tracing provider")
@field_validator("tracing_provider")
@classmethod
def validate_tracing_provider(cls, value: str | None, info) -> str | None:
if info.data.get("enabled") and not value:
raise ValueError("tracing_provider is required when enabled is True")
return value
class AppTraceResponse(ResponseModel):
enabled: bool = False
tracing_provider: str | None = None
class Tag(ResponseModel):
id: str
name: str
type: str
class WorkflowPartial(ResponseModel):
id: str
created_by: str | None = None
created_at: int | None = NoneView on GitHub (pinned to ef8544b173)
Solutions
- Include a valid tracing_provider value (e.g., 'langfuse', 'langsmith', 'opik') whenever enabled is true.
- If disabling, send {enabled: false} and tracing_provider can be omitted.
- Make the UI require a provider selection before the enable toggle can be flipped on.
- Validate the payload shape before submitting.
Example fix
// before
axios.put(`/apps/${id}/trace`, { enabled: true })
// after
axios.put(`/apps/${id}/trace`, { enabled: true, tracing_provider: 'langfuse' }) Defensive patterns
Strategy: validation
Validate before calling
function buildTracePayload(enabled, provider) {
if (enabled && !provider) throw new Error('tracing_provider is required when enabled is true');
return { enabled, tracing_provider: enabled ? provider : provider ?? null };
} Type guard
const isProviderSetWhenEnabled = (p) => !p.enabled || (typeof p.tracing_provider === 'string' && p.tracing_provider.length > 0);
Try / catch
try { await axios.put(`/apps/${id}/trace`, payload); }
catch (e) { if (/tracing_provider is required/.test(e.message)) { /* prompt user to pick a provider */ } } Prevention
- Force the user to choose a provider before the enable toggle flips on.
- Default the provider field to a known value in the UI.
- Validate the payload client-side before submitting.
When it happens
Trigger: Sending {enabled: true} (or with tracing_provider omitted/null/empty string) to enable tracing without naming a provider. The validator runs after the 'enabled' field is parsed, so it can read info.data.get('enabled').
Common situations: Frontend toggles the 'enable tracing' switch without selecting a provider from the dropdown; default provider state not initialized; malformed payload from a script that only sets the flag.
Related errors
- Unsupported tag_ids type.
- Invalid UUID format in tag_ids.
- Unsupported creator_ids type.
- Invalid UUID format in creator_ids.
- KNOWLEDGE_FS_BASE_URL must be an absolute HTTP(S) URL
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/c4880b3007ebcace.
Report an issue: GitHub.