You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Built-in metadata written at document creation uses a different format, breaking time filters on upload_date / last_update_date #44217
DocumentService.build_document (documents created after built-in fields are enabled)
"2026-10-16 08:00:00" (string)
raw data_source_type, e.g. upload_file
PipelineGenerator._build_document (knowledge pipeline, copied from the above)
same string
same raw value
time filters compile to CAST(doc_metadata ->> 'upload_date' AS FLOAT), so a single string-formatted document makes the whole query fail on PostgreSQL. I ran the SQL produced by DatasetRetrieval.process_metadata_filter_func against a minimal documents table on PostgreSQL 15 holding one row in each format:
upload_date before 1893456000 -> InvalidTextRepresentation: invalid input syntax for type double precision: "2026-10-16 08:00:00"
upload_date after 0 -> InvalidTextRepresentation: invalid input syntax for type double precision: "2026-10-16 08:00:00"
source is 'file_upload' -> only the document written by _built_in is returned
(Verified at the SQL level with Dify's own filter function, not through a full end-to-end deployment.)
Both formats were introduced together in #15982; the knowledge pipeline later copied the build_document version in #25360.
✔️ Expected Behavior
Every document stores built-in fields in the same format: epoch seconds for the time fields and the MetadataDataSource label for source, the same label the document detail page shows (format_document_built_in_fields). Time filters and source filters then work for all documents.
❌ Actual Behavior
Filtering on upload_date / last_update_date with before / after / < / > fails the Knowledge Retrieval node with a PostgreSQL cast error once any document has been created after built-in fields were enabled.
Filtering source is file_upload (the value shown in the UI) silently skips those documents, because they store upload_file.
Hi @cty-ut! I'm Dosu and I'm helping the Dify team.
Thanks for the detailed reproduction. The checked-out code matches the mismatch you described: both creation paths write formatted date strings and raw source values, while _built_in writes numeric timestamps and mapped source labels. [1][2][3]
For your fix, I’d suggest regression coverage across all three writers, asserting the same stored types and source labels, plus PostgreSQL retrieval tests for both date fields and source equality. The filter implementation uses .as_float() for date comparisons, so testing only the generated metadata would miss the failing query behavior. [4]
One scope point to flag for maintainers: correcting the creation paths alone would leave previously stored malformed values untouched, since these assignments apply to newly constructed documents. Please include that existing-data concern in the fix description so maintainers can decide on an official migration strategy. [5][6]
Activity
dosubot commentedon Oct 16, 2026
Hi @cty-ut! I'm Dosu and I'm helping the Dify team.
Thanks for the detailed reproduction. The checked-out code matches the mismatch you described: both creation paths write formatted date strings and raw source values, while
_built_inwrites numeric timestamps and mapped source labels. [1] [2] [3]For your fix, I’d suggest regression coverage across all three writers, asserting the same stored types and source labels, plus PostgreSQL retrieval tests for both date fields and source equality. The filter implementation uses
.as_float()for date comparisons, so testing only the generated metadata would miss the failing query behavior. [4]One scope point to flag for maintainers: correcting the creation paths alone would leave previously stored malformed values untouched, since these assignments apply to newly constructed documents. Please include that existing-data concern in the fix description so maintainers can decide on an official migration strategy. [5] [6]
To reply, just mention @dosu.
Docs are dead. Just use Dosu.