langgenius/dify · error · ValueError
deleted environment variable ids must not be empty
Error message
deleted environment variable ids must not be empty
What it means
Raised by SyncEnvironmentVariablePatchPayload.validate_patch when deleted_environment_variable_ids contains an empty or otherwise falsy entry (api/controllers/console/app/workflow.py:131-132). Every id in the delete list must be a non-empty string so the service can target a concrete row. Empty strings (or nulls coerced from malformed input) are rejected. Surfaced as a Pydantic ValidationError (400).
Source
Thrown at api/controllers/console/app/workflow.py:132
name: NotRequired[str]
value: NotRequired[Any]
description: NotRequired[str | None]
class SyncEnvironmentVariablePatchPayload(BaseModel):
environment_variables: list[dict[str, Any]] = Field(default_factory=list)
deleted_environment_variable_ids: list[str] = Field(default_factory=list)
@model_validator(mode="after")
def validate_patch(self) -> Self:
"""Require stable, disjoint IDs so the service can merge the patch deterministically."""
upsert_ids = [variable.get("id") for variable in self.environment_variables]
if any(not isinstance(variable_id, str) or not variable_id for variable_id in upsert_ids):
raise ValueError("patched environment variables require an id")
if len(set(upsert_ids)) != len(upsert_ids):
raise ValueError("patched environment variable ids must be unique")
if any(not variable_id for variable_id in self.deleted_environment_variable_ids):
raise ValueError("deleted environment variable ids must not be empty")
if len(set(self.deleted_environment_variable_ids)) != len(self.deleted_environment_variable_ids):
raise ValueError("deleted environment variable ids must be unique")
if set(upsert_ids).intersection(self.deleted_environment_variable_ids):
raise ValueError("an environment variable cannot be upserted and deleted in the same patch")
return self
class SyncDraftWorkflowPayload(BaseModel):
model_config = ConfigDict(extra="forbid")
graph: dict[str, Any]
features: dict[str, Any]
hash: str | None = None
is_collaborative: bool = Field(default=False, alias="_is_collaborative")
environment_variable_patch: SyncEnvironmentVariablePatchPayload | None = None
conversation_variables: list[dict[str, Any]] = Field(
default_factory=list,
)View on GitHub (pinned to ef8544b173)
Solutions
- Filter out empty/falsy ids from deleted_environment_variable_ids before submitting: `ids.filter(Boolean)`.
- Ensure the front-end only pushes a deletion id once the user confirms a real variable.
- Add a client-side check that all entries are non-empty strings.
Example fix
// before: blank entry included deleted_environment_variable_ids: ['', 'abc'] // after: filter blanks deleted_environment_variable_ids: ['', 'abc'].filter(Boolean)
Defensive patterns
Strategy: validation
Validate before calling
// Drop falsy ids from the delete list before submit payload.deleted_environment_variable_ids = payload.deleted_environment_variable_ids.filter(id => typeof id === 'string' && id.length > 0)
Type guard
function cleanDeletes(ids) {
return Array.isArray(ids) && ids.every(id => typeof id === 'string' && id.length > 0)
} Prevention
- Filter blank ids from form state before serializing.
- Use a controlled input that rejects empty values.
When it happens
Trigger: Sending deleted_environment_variable_ids like ['', 'abc'] or [null]. Happens when the front-end pushes an empty string placeholder or includes a null slot from a form.
Common situations: Front-end bug appending an empty input value; serialized form with a blank row; refactoring that left a default '' in the array; client not filtering blanks before submit.
Related errors
- patched environment variables require an id
- patched environment variable ids must be unique
- deleted environment variable ids must be unique
- an environment variable cannot be upserted and deleted in th
- Unsupported environment variable value type: {value_type}
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/e79d97e259d34217.
Report an issue: GitHub.