langgenius/dify · error · ValueError
Unsupported environment variable value type: {value_type}
Error message
Unsupported environment variable value type: {value_type} What it means
Raised by _serialize_environment_variable when a dict-form environment variable's value_type maps (via SegmentType(...).exposed_type()) to a type not in ENVIRONMENT_VARIABLE_SUPPORTED_TYPES (api/controllers/console/app/workflow.py:555-557). The serializer refuses to emit unsupported value types to keep the draft/workflow contract stable. Note the message interpolates the resolved exposed type, not the raw string.
Source
Thrown at api/controllers/console/app/workflow.py:557
return {
"id": value.id,
"name": value.name,
"value": value.value,
"value_type": str(value.value_type.exposed_type()),
"description": value.description,
}
case dict():
value_type_str = value.get("value_type")
if not isinstance(value_type_str, str):
raise TypeError(
f"unexpected type for value_type field, value={value_type_str}, type={type(value_type_str)}"
)
if value_type_str == LLM_ENVIRONMENT_VARIABLE_VALUE_TYPE:
return value
value_type = SegmentType(value_type_str).exposed_type()
if value_type not in ENVIRONMENT_VARIABLE_SUPPORTED_TYPES:
raise ValueError(f"Unsupported environment variable value type: {value_type}")
return value
case _:
return value
@console_ns.route("/apps/<uuid:app_id>/workflows/draft")
class DraftWorkflowApi(Resource):
@console_ns.doc("get_draft_workflow")
@console_ns.doc(description="Get draft workflow for an application")
@console_ns.doc(params={"app_id": "Application ID"})
@console_ns.response(
200,
"Draft workflow retrieved successfully",
console_ns.models[WorkflowResponse.__name__],
)
@console_ns.response(404, "Draft workflow not found")
@setup_requiredView on GitHub (pinned to ef8544b173)
Solutions
- Use only value_type values backed by ENVIRONMENT_VARIABLE_SUPPORTED_TYPES (string, number, bool, object, array[string], etc.).
- If a new type is genuinely needed, extend ENVIRONMENT_VARIABLE_SUPPORTED_TYPES and SegmentType support together.
- Align client and backend versions so the client only sends types the backend recognizes.
- Inspect the rejected variable's value_type in the request payload and replace it with a supported equivalent.
Example fix
// before: unsupported value type
{value_type: 'file', value: ...}
// after: use a supported type (e.g. string url)
{value_type: 'string', value: 'https://...'} Defensive patterns
Strategy: type-guard
Validate before calling
// Restrict value_type to the backend allowlist before submit
const ALLOWED = ['string','number','bool','object','array[string]','array[number]','array[object]']
vars.forEach(v => { if (!ALLOWED.includes(v.value_type)) v.value_type = 'string' }) Type guard
const ALLOWED = new Set(['string','number','bool','object','array[string]','array[number]','array[object]'])
function isSupportedType(t) { return typeof t === 'string' && ALLOWED.has(t) } Prevention
- Keep the client's type list in sync with ENVIRONMENT_VARIABLE_SUPPORTED_TYPES.
- Reject unsupported types in the form before submit.
- Align client/backend versions.
When it happens
Trigger: Syncing a draft workflow whose environment_variables (or conversation_variables routed through the same serializer) include a value_type that resolves to an unsupported SegmentType exposed type. Bypasses front-end type lists and submits a raw type string.
Common situations: Front-end sending a new/custom value type before the backend allowlist (ENVIRONMENT_VARIABLE_SUPPORTED_TYPES) was extended; payload tampering; version skew between a newer client and an older backend that lacks the new type; import from an external graph format with foreign type names.
Related errors
- patched environment variables require an id
- patched environment variable ids must be unique
- deleted environment variable ids must not be empty
- deleted environment variable ids must be unique
- an environment variable cannot be upserted and deleted in th
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/5bd35d3594cd49fa.
Report an issue: GitHub.