Dataset write failures (400/500) on Knowledge API for dataset c42d3e12-57f3-4b12-a91a-15aa12c78aa2 #18202

Closed
opened 2026-02-21 19:44:50 -05:00 by yindo · 0 comments
Owner

Originally created by @jtinnerello1 on GitHub (Sep 25, 2025).

Originally assigned to: @JohnJyong on GitHub.

Self Checks

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

Dify version

Version 1.9.0

Cloud or Self Hosted

Cloud

Steps to reproduce

Dataset write failures (400/500) on Knowledge API for dataset c42d3e12-57f3-4b12-a91a-15aa12c78aa2

Hello Dify Support,
We’re seeing consistent write failures against the Knowledge API for a dataset in our workspace.
Dataset:
Name: contracts,
ID: c42d3e12-57f3-4b12-a91a-15aa12c78aa2,
Endpoint base: https://api.dify.ai/v1,
Workspace: Joseph Tinnerello’s Workspace (cloud UI),
Symptoms:

GET /v1/datasets/{id} → 200 OK (works)
POST /v1/datasets/{id}/document/create-by-text (Content-Type: application/json) Body: { "text": "post-regenerate 2025-09-24T04:03:18Z", "name": "diag-20250924-040318", "indexing_technique": "high_quality" } Result: 500 Body: {"message":"Internal Server Error","code":"unknown","status":500}
POST /v1/datasets/{id}/document/create-by-file (multipart form) Form fields: file=@diag-demo.txt, data={"indexing_technique":"high_quality"} Result: 400 Body: {"code":"invalid_param","message":"Invalid user account","status":400} What we tried: Verified dataset GET with both old and newly generated dataset keys.,

Generated a NEW dataset key from Knowledge → contracts → Service API (key prefix dataset-…).,
Retried both text and file ingestion with the new dataset key., Text with multipart form (earlier) returned 400 "Missing required parameter in the JSON body" (expected), so we switched to JSON body per docs, then received 500.,

Request: Please confirm whether dataset-scoped keys currently support both create-by-text and create-by-file., If yes, please investigate why a fresh dataset key yields 500 for text and 400 "Invalid user account" for file on this dataset., If there is a migration/permission toggle required on your side, please apply it or advise.,
We can provide exact timestamps and HAR if helpful.

Thank you!

✔️ Expected Behavior

Expected behavior

Dataset read:
GET https://api.dify.ai/v1/datasets/{DATASET_ID} with a Dataset API key should return 200 OK with dataset metadata.

Text ingest:
POST https://api.dify.ai/v1/datasets/{DATASET_ID}/document/create-by-text with header Authorization: Bearer <DATASET_API_KEY> and JSON body
{"text":"","name":"","indexing_technique":"high_quality"} should return 200 with a JSON payload containing a document id (and/or an indexing job/state). If the JSON is malformed or required fields are missing, the API should return a 4xx validation error, not a 5xx.

File ingest:
POST https://api.dify.ai/v1/datasets/{DATASET_ID}/document/create-by-file with the same Dataset API key and multipart/form-data parts
file=@;type= and data={"indexing_technique":"high_quality"} should return 200 with a JSON payload containing a document id (and/or indexing job/state). If form parts are missing, the API should return a 4xx validation error, not an account error.

Actual Behavior

Actual behavior

Dataset read (works as expected):
GET /v1/datasets/c42d3e12-57f3-4b12-a91a-15aa12c78aa2 with Dataset API key returns 200 OK and full dataset metadata. (Confirms the key is valid and the dataset exists.)

Text ingest (server error):
POST /v1/datasets/{ID}/document/create-by-text with header Authorization: Bearer dataset-***********… and body:

{"text":"post-regenerate 2025-09-24T04:03:00Z","name":"diag-20250924-040300","indexing_technique":"high_quality"}

consistently returns 500 Internal Server Error with JSON:
{"message":"Internal Server Error","code":"unknown","status":500}.
Earlier attempts using -Form (multipart) returned 400 {"errors":{"name":"Missing required parameter in the JSON body"}}, which is expected for wrong content-type, but after switching to proper application/json the endpoint still fails with 500.

File ingest (account error despite valid key):
POST /v1/datasets/{ID}/document/create-by-file (multipart: file=@diag-demo.txt;type=text/plain, data={"indexing_technique":"high_quality"}) with the same Dataset API key returns 400 with JSON:
{"code":"invalid_param","message":"Invalid user account","status":400}.
This occurs even though the same key successfully GETs the dataset (200).
Behavior is identical with both the previous Dataset key and a newly regenerated Dataset key (last 6 chars: …hjpwecRzS).
Base URL used: https://api.dify.ai (path includes /v1).

Repro details (for Dify to copy/paste)

Text ingest (JSON, PowerShell):

$BASE='https://api.dify.ai'
$ID='c42d3e12-57f3-4b12-a91a-15aa12c78aa2'
$KEY='dataset-********' # Dataset API key
$body = @{ text = "canary $(Get-Date -Format o)"; name = "canary-$(Get-Date -Format yyyyMMdd-HHmmss)"; indexing_technique = "high_quality" } | ConvertTo-Json
Invoke-WebRequest -Uri "$BASE/v1/datasets/$ID/document/create-by-text" -Headers @{ Authorization = "Bearer $KEY"; "Content-Type"="application/json" } -Method POST -Body $body -SkipHttpErrorCheck

Actual: 500 {"message":"Internal Server Error","code":"unknown","status":500}

File ingest (multipart, curl):

Set-Content .\canary.txt "canary $(Get-Date -Format o)"
curl.exe -sS -i -X POST "$BASE/v1/datasets/$ID/document/create-by-file" -H "Authorization: Bearer %KEY%"
-F "file=@canary.txt;type=text/plain" `
-F "data={"indexing_technique":"high_quality"}"

Actual: 400 {"code":"invalid_param","message":"Invalid user account","status":400}

Context/notes for triage

Same Dataset API key can read the dataset (200) but cannot create a document by file (400 “Invalid user account”) and fails on text ingest with 500.

Behavior unchanged after key regeneration.

Goal is to confirm whether Dataset-scoped keys created in Knowledge → Datasets are expected to support both create-by-text and create-by-file, and what “Invalid user account” precisely indicates (scope mismatch? workspace/tenant boundary? permission model change?).

Ask: Please confirm the correct key type/scope and any required headers for these endpoints, and advise why create-by-text returns a 500 with a well-formed JSON payload.

Originally created by @jtinnerello1 on GitHub (Sep 25, 2025). Originally assigned to: @JohnJyong on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/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 Version 1.9.0 ### Cloud or Self Hosted Cloud ### Steps to reproduce Dataset write failures (400/500) on Knowledge API for dataset c42d3e12-57f3-4b12-a91a-15aa12c78aa2 Hello Dify Support, We’re seeing consistent write failures against the Knowledge API for a dataset in our workspace. Dataset: Name: contracts, ID: c42d3e12-57f3-4b12-a91a-15aa12c78aa2, Endpoint base: https://api.dify.ai/v1, Workspace: Joseph Tinnerello’s Workspace (cloud UI), Symptoms: GET /v1/datasets/{id} → 200 OK (works) POST /v1/datasets/{id}/document/create-by-text (Content-Type: application/json) Body: { "text": "post-regenerate 2025-09-24T04:03:18Z", "name": "diag-20250924-040318", "indexing_technique": "high_quality" } Result: 500 Body: {"message":"Internal Server Error","code":"unknown","status":500} POST /v1/datasets/{id}/document/create-by-file (multipart form) Form fields: file=@diag-demo.txt, data={"indexing_technique":"high_quality"} Result: 400 Body: {"code":"invalid_param","message":"Invalid user account","status":400} What we tried: Verified dataset GET with both old and newly generated dataset keys., Generated a NEW dataset key from Knowledge → contracts → Service API (key prefix dataset-…)., Retried both text and file ingestion with the new dataset key., Text with multipart form (earlier) returned 400 "Missing required parameter in the JSON body" (expected), so we switched to JSON body per docs, then received 500., Request: Please confirm whether dataset-scoped keys currently support both create-by-text and create-by-file., If yes, please investigate why a fresh dataset key yields 500 for text and 400 "Invalid user account" for file on this dataset., If there is a migration/permission toggle required on your side, please apply it or advise., We can provide exact timestamps and HAR if helpful. Thank you! ### ✔️ Expected Behavior Expected behavior Dataset read: GET https://api.dify.ai/v1/datasets/{DATASET_ID} with a Dataset API key should return 200 OK with dataset metadata. Text ingest: POST https://api.dify.ai/v1/datasets/{DATASET_ID}/document/create-by-text with header Authorization: Bearer <DATASET_API_KEY> and JSON body {"text":"<content>","name":"<string>","indexing_technique":"high_quality"} should return 200 with a JSON payload containing a document id (and/or an indexing job/state). If the JSON is malformed or required fields are missing, the API should return a 4xx validation error, not a 5xx. File ingest: POST https://api.dify.ai/v1/datasets/{DATASET_ID}/document/create-by-file with the same Dataset API key and multipart/form-data parts file=@<path>;type=<mime> and data={"indexing_technique":"high_quality"} should return 200 with a JSON payload containing a document id (and/or indexing job/state). If form parts are missing, the API should return a 4xx validation error, not an account error. ### ❌ Actual Behavior Actual behavior Dataset read (works as expected): GET /v1/datasets/c42d3e12-57f3-4b12-a91a-15aa12c78aa2 with Dataset API key returns 200 OK and full dataset metadata. (Confirms the key is valid and the dataset exists.) Text ingest (server error): POST /v1/datasets/{ID}/document/create-by-text with header Authorization: Bearer dataset-***********… and body: {"text":"post-regenerate 2025-09-24T04:03:00Z","name":"diag-20250924-040300","indexing_technique":"high_quality"} consistently returns 500 Internal Server Error with JSON: {"message":"Internal Server Error","code":"unknown","status":500}. Earlier attempts using -Form (multipart) returned 400 {"errors":{"name":"Missing required parameter in the JSON body"}}, which is expected for wrong content-type, but after switching to proper application/json the endpoint still fails with 500. File ingest (account error despite valid key): POST /v1/datasets/{ID}/document/create-by-file (multipart: file=@diag-demo.txt;type=text/plain, data={"indexing_technique":"high_quality"}) with the same Dataset API key returns 400 with JSON: {"code":"invalid_param","message":"Invalid user account","status":400}. This occurs even though the same key successfully GETs the dataset (200). Behavior is identical with both the previous Dataset key and a newly regenerated Dataset key (last 6 chars: …hjpwecRzS). Base URL used: https://api.dify.ai (path includes /v1). Repro details (for Dify to copy/paste) Text ingest (JSON, PowerShell): $BASE='https://api.dify.ai' $ID='c42d3e12-57f3-4b12-a91a-15aa12c78aa2' $KEY='dataset-********' # Dataset API key $body = @{ text = "canary $(Get-Date -Format o)"; name = "canary-$(Get-Date -Format yyyyMMdd-HHmmss)"; indexing_technique = "high_quality" } | ConvertTo-Json Invoke-WebRequest -Uri "$BASE/v1/datasets/$ID/document/create-by-text" -Headers @{ Authorization = "Bearer $KEY"; "Content-Type"="application/json" } -Method POST -Body $body -SkipHttpErrorCheck Actual: 500 {"message":"Internal Server Error","code":"unknown","status":500} File ingest (multipart, curl): Set-Content .\canary.txt "canary $(Get-Date -Format o)" curl.exe -sS -i -X POST "$BASE/v1/datasets/$ID/document/create-by-file" ` -H "Authorization: Bearer %KEY%" ` -F "file=@canary.txt;type=text/plain" ` -F "data={\"indexing_technique\":\"high_quality\"}" Actual: 400 {"code":"invalid_param","message":"Invalid user account","status":400} Context/notes for triage Same Dataset API key can read the dataset (200) but cannot create a document by file (400 “Invalid user account”) and fails on text ingest with 500. Behavior unchanged after key regeneration. Goal is to confirm whether Dataset-scoped keys created in Knowledge → Datasets are expected to support both create-by-text and create-by-file, and what “Invalid user account” precisely indicates (scope mismatch? workspace/tenant boundary? permission model change?). Ask: Please confirm the correct key type/scope and any required headers for these endpoints, and advise why create-by-text returns a 500 with a well-formed JSON payload.
yindo added the 🐞 bugcloud labels 2026-02-21 19:44:50 -05:00
yindo closed this issue 2026-02-21 19:44:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#18202