{"record":{"id":"6a127f48bf1d323c","repo":"langgenius/dify","slug":"timestamp-is-required","errorCode":null,"errorMessage":"timestamp is required","messagePattern":"timestamp is required","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/app/workflow.py","lineNumber":338,"sourceCode":"    created_by: SimpleAccount | None = Field(\n        default=None, validation_alias=AliasChoices(\"created_by_account\", \"created_by\")\n    )\n    created_at: int\n    updated_by: SimpleAccount | None = Field(\n        default=None, validation_alias=AliasChoices(\"updated_by_account\", \"updated_by\")\n    )\n    updated_at: int\n    tool_published: bool\n    environment_variables: list[WorkflowEnvironmentVariableResponse]\n    conversation_variables: list[WorkflowConversationVariableResponse]\n    rag_pipeline_variables: list[PipelineVariableResponse]\n\n    @field_validator(\"created_at\", \"updated_at\", mode=\"before\")\n    @classmethod\n    def _normalize_timestamp(cls, value: datetime | int | None) -> int:\n        timestamp = to_timestamp(value)\n        if timestamp is None:\n            raise ValueError(\"timestamp is required\")\n        return timestamp\n\n    @field_validator(\"environment_variables\", mode=\"before\")\n    @classmethod\n    def _serialize_environment_variables(cls, value: Any) -> list[Any]:\n        if value is None:\n            return []\n\n        return [_serialize_environment_variable(item) for item in value]\n\n\nclass _WorkflowResponseSource:\n    def __init__(self, workflow: Workflow, *, session: Session) -> None:\n        self._workflow = workflow\n        self._session = session\n\n    def __getattr__(self, name: str) -> object:\n        return getattr(self._workflow, name)  # guard-ignore: no-new-getattr -- delegates model fields","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/workflow.py#L320-L356","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// (Server-side) Backfill null timestamps before serializing\n// SELECT id FROM workflows WHERE created_at IS NULL OR updated_at IS NULL\n// then UPDATE with a valid epoch","typeGuard":null,"tryCatchPattern":"try {\n  return await getDraftWorkflow(appId)\n} catch (e) {\n  if (/timestamp is required/.test(e.message)) { reportDataIssue(appId); throw e }\n  throw e\n}","preventionTips":["Ensure all workflow rows have non-null created_at/updated_at.","Audit data after migrations for missing timestamps.","Never INSERT workflows without timestamps."],"tags":["workflow","serialization","timestamp","response","api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}