Back Home

GitHub Repo

Dify Community Reports Inconsistent Date Formats, Potentially Causing Entire Knowledge Base Queries to Fail

A Dify community report on October 16 says inconsistent write formats for built-in metadata may cause time filters to fail or source filters to miss documents. A proposed fix has been submitted but not merged, and does not include migration of existing data.

The original uploader was Ggia at Greek Wikipedia. · CC BY-SA 2.5 · Image source
zh-Hant

On October 16, the Dify community filed an issue report and proposed a fix, pointing to inconsistent formats for built-in knowledge base metadata: dates backfilled when fields are enabled are numeric timestamps, while documents added later are written with date strings. The report covers self-hosted version 1.17.1 and says the same code path was still present on the main branch at the time. Verification was limited to SQL tests on PostgreSQL 15, rather than a full deployment reproduction. Issue report

According to the report, enabling built-in fields and using the batch-edit workflow writes upload_date and last_update_date as epoch seconds; ordinary document creation and knowledge pipelines use strings in year-month-day-hour-minute-second format. Time conditions cast the field to FLOAT, so a single date string mixed in with the numeric values could cause the entire retrieval query to fail during conversion. The source field also differs between file_upload and upload_file, which may silently cause documents to be omitted from equality filters. Technical details

This could affect RAG applications that restrict data by date. Dify’s official design already allows manual or automatic metadata conditions in knowledge retrieval nodes and uses time fields to distinguish document versions. As an engineering inference, if the format issue occurs at this layer, changing the embedding or reranking model would not fix a failed query; engineers should first check data types and filter conditions. Official feature documentation

The proposed fix consolidates the three write paths into a shared function, standardizes timestamps and source labels, and addresses the time conversion’s dependence on the process time zone. The author reports that 2,318 related unit tests passed, but this result is provided by the submitter. As of the report’s review, the PR is still awaiting review and does not migrate existing records. Engineers should watch for the PR’s merge and release version, as well as an official remediation method for older data. Deployment validation should cover both new and existing documents, date comparisons, and source equality filters. Proposed fix

Sources

  1. Built-in metadata written at document creation uses a different format
  2. fix(api): write built-in document metadata in a single format
  3. Dify v1.1.0: Filtering Knowledge Retrieval with Customized Metadata