dify icon indicating copy to clipboard operation
dify copied to clipboard

Service API create-by-text returns 400 when indexing_technique is omitted, even if the knowledge base has one

Open cty-ut opened this issue 1 day ago • 1 comments

Self Checks

  • [x] I have read the Contributing Guide and Language Policy.
  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report, otherwise it will be closed.
  • [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.18.0 (the same code path is in 1.20.0 and on main)

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Use a knowledge base that already has an indexing technique, for example one created in the console with documents in it.
  2. Add a document through the Service API without indexing_technique:
curl -X POST "http://localhost/v1/datasets/<dataset_id>/document/create-by-text" \
  -H "Authorization: Bearer <dataset_api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name": "probe", "text": "hello"}'

✔️ Expected Behavior

The document is created with the knowledge base's indexing technique. The field description says: "Required when adding the first document to a knowledge base; subsequent documents inherit the knowledge base's indexing technique if omitted."

create-by-file already works this way.

❌ Actual Behavior

The request fails with 400:

1 validation error for KnowledgeConfig
indexing_technique
  Field required

create_by_text checks that the knowledge base has an indexing technique, but does not add it to the settings that KnowledgeConfig validates.

The text is uploaded before this validation, so each failed request also leaves an unused row in upload_files.

cty-ut avatar Dec 04 '26 08:12 cty-ut

This is a runtime mismatch with the documented behavior. Until #47814 ships, pass the knowledge base’s existing indexing_technique explicitly in create-by-text requests. The text path checks the dataset’s value but doesn’t pass it to KnowledgeConfig; create-by-file puts the resolved value into the settings before validation [1] [2] [3] [4].

One detail for triage: on the current checkout, this 400 can leave both a storage blob and a committed upload_files row. The row is unattached, but it’s marked used=True, so it shouldn’t be treated as an unused row for cleanup [5] [6] [7] [8] [9].

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about dify

dosubot[bot] avatar Dec 04 '26 08:12 dosubot[bot]