langgenius/dify · error · ValueError
timestamp is required
Error message
timestamp is required
What it means
Raised by the _normalize_timestamp field_validator on WorkflowResponse.created_at/updated_at when to_timestamp(value) returns None (api/controllers/console/app/workflow.py:333-338). Both fields must resolve to a valid integer epoch timestamp; if the source value is an unparseable datetime or None and cannot be converted, the response serialization itself fails with this ValueError (during Pydantic validation of the workflow object).
Source
Thrown at api/controllers/console/app/workflow.py:338
created_by: SimpleAccount | None = Field(
default=None, validation_alias=AliasChoices("created_by_account", "created_by")
)
created_at: int
updated_by: SimpleAccount | None = Field(
default=None, validation_alias=AliasChoices("updated_by_account", "updated_by")
)
updated_at: int
tool_published: bool
environment_variables: list[WorkflowEnvironmentVariableResponse]
conversation_variables: list[WorkflowConversationVariableResponse]
rag_pipeline_variables: list[PipelineVariableResponse]
@field_validator("created_at", "updated_at", mode="before")
@classmethod
def _normalize_timestamp(cls, value: datetime | int | None) -> int:
timestamp = to_timestamp(value)
if timestamp is None:
raise ValueError("timestamp is required")
return timestamp
@field_validator("environment_variables", mode="before")
@classmethod
def _serialize_environment_variables(cls, value: Any) -> list[Any]:
if value is None:
return []
return [_serialize_environment_variable(item) for item in value]
class _WorkflowResponseSource:
def __init__(self, workflow: Workflow, *, session: Session) -> None:
self._workflow = workflow
self._session = session
def __getattr__(self, name: str) -> object:
return getattr(self._workflow, name) # guard-ignore: no-new-getattr -- delegates model fieldsView on GitHub (pinned to ef8544b173)
Solutions
- Inspect the Workflow row in the DB — confirm created_at and updated_at are non-null and hold valid timestamps.
- Backfill NULL timestamps for affected workflow rows (e.g. set them to a known epoch value).
- If a datetime format is the cause, normalize stored values to a consistent UTC datetime before serialization.
- Reproduce by GET /apps/{app_id}/workflows/draft for the failing app and inspect the workflow row.
Defensive patterns
Strategy: validation
Validate before calling
// (Server-side) Backfill null timestamps before serializing // SELECT id FROM workflows WHERE created_at IS NULL OR updated_at IS NULL // then UPDATE with a valid epoch
Try / catch
try {
return await getDraftWorkflow(appId)
} catch (e) {
if (/timestamp is required/.test(e.message)) { reportDataIssue(appId); throw e }
throw e
} Prevention
- Ensure all workflow rows have non-null created_at/updated_at.
- Audit data after migrations for missing timestamps.
- Never INSERT workflows without timestamps.
When it happens
Trigger: Building a WorkflowResponse from a Workflow whose created_at/updated_at is null or holds a value to_timestamp cannot coerce (e.g. a tz-naive datetime in an unexpected format, or null because the row was inserted without timestamps). The error occurs at response-build time on GET draft/published workflow endpoints.
Common situations: Workflow row with NULL created_at/updated_at (legacy/migrated data); DB timezone misconfiguration producing an unparseable value; manual INSERT that skipped timestamps; schema migration that left timestamps unset.
Related errors
- Unsupported environment variable value type: {value_type}
- 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
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/6a127f48bf1d323c.
Report an issue: GitHub.