{"record":{"id":"5bd35d3594cd49fa","repo":"langgenius/dify","slug":"unsupported-environment-variable-value-type-valu","errorCode":null,"errorMessage":"Unsupported environment variable value type: {value_type}","messagePattern":"Unsupported environment variable value type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/app/workflow.py","lineNumber":557,"sourceCode":"            return {\n                \"id\": value.id,\n                \"name\": value.name,\n                \"value\": value.value,\n                \"value_type\": str(value.value_type.exposed_type()),\n                \"description\": value.description,\n            }\n\n        case dict():\n            value_type_str = value.get(\"value_type\")\n            if not isinstance(value_type_str, str):\n                raise TypeError(\n                    f\"unexpected type for value_type field, value={value_type_str}, type={type(value_type_str)}\"\n                )\n            if value_type_str == LLM_ENVIRONMENT_VARIABLE_VALUE_TYPE:\n                return value\n            value_type = SegmentType(value_type_str).exposed_type()\n            if value_type not in ENVIRONMENT_VARIABLE_SUPPORTED_TYPES:\n                raise ValueError(f\"Unsupported environment variable value type: {value_type}\")\n            return value\n\n        case _:\n            return value\n\n\n@console_ns.route(\"/apps/<uuid:app_id>/workflows/draft\")\nclass DraftWorkflowApi(Resource):\n    @console_ns.doc(\"get_draft_workflow\")\n    @console_ns.doc(description=\"Get draft workflow for an application\")\n    @console_ns.doc(params={\"app_id\": \"Application ID\"})\n    @console_ns.response(\n        200,\n        \"Draft workflow retrieved successfully\",\n        console_ns.models[WorkflowResponse.__name__],\n    )\n    @console_ns.response(404, \"Draft workflow not found\")\n    @setup_required","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/workflow.py#L539-L575","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: unsupported value type\n{value_type: 'file', value: ...}\n// after: use a supported type (e.g. string url)\n{value_type: 'string', value: 'https://...'}","handlingStrategy":"type-guard","validationCode":"// Restrict value_type to the backend allowlist before submit\nconst ALLOWED = ['string','number','bool','object','array[string]','array[number]','array[object]']\nvars.forEach(v => { if (!ALLOWED.includes(v.value_type)) v.value_type = 'string' })","typeGuard":"const ALLOWED = new Set(['string','number','bool','object','array[string]','array[number]','array[object]'])\nfunction isSupportedType(t) { return typeof t === 'string' && ALLOWED.has(t) }","tryCatchPattern":null,"preventionTips":["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."],"tags":["workflow","environment-variables","unsupported-type","serialization","api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}