Skip to content

fix(nodejs-client): allow long knowledge document text - #44679

Merged
crazywoola merged 1 commit into
langgenius:mainfrom
Winoren:fix/node-document-text-length
Oct 30, 2026
Merged

crazywoola merged 1 commit into
langgenius:mainfrom
Winoren:fix/node-document-text-length

Conversation

@Winoren

@Winoren Winoren commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #44678.

A 10,001-character knowledge document is rejected before the Node.js SDK sends any HTTP request, even though the document API accepts it. Creation hits the method's generic string limit; updating hits the separate HTTP body validator. Changing only one layer leaves the other failure intact.

Keep the generic limits as defaults and add a per-request exemption for named body string fields. Only text on document create/update opts in. Creation still validates that text is a non-empty string. Names, IDs, query strings, other body fields, and other requests retain their existing checks. No dependencies change.

Verification

  • Before the fix: the new HTTP-boundary regression tests fail at 10,001 and 50,000 characters (2 failed, 7 passed in the targeted file). A built-SDK probe against a native Node HTTP fixture separately confirms both create and update send zero requests at those sizes.
  • After the fix: all 152 Node SDK tests pass across 15 files, including full JSON-body preservation for create/update at 10,000, 10,001, and 50,000 characters; invalid create-text inputs and non-exempt string limits are also checked.
  • tsc --noEmit, SDK vp pack, and repository-config Oxlint and Oxfmt checks on all five changed files pass. The lint/format config was loaded through a temporary root re-export of packages/tooling/repository.config.ts to resolve workspace tooling in the isolated checkout; the temporary file is not part of this PR.
  • The built SDK sends all six create/update fixture requests successfully after the fix. Separately, two backend contract cases validate the actual DocumentTextCreatePayload / DocumentTextUpdate and persist 10,001/50,000 characters through actual FileService.upload_text, SQLite and filesystem OpenDAL storage, verifying the saved content and byte size.
  • These are local SDK/contract/storage checks, not a deployed Dify API or indexing-pipeline test. Remote CI is separate.

Screenshots

Before After
Long document text throws ValidationError without sending a request. Create/update sends the complete document text.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

SDK-scoped validation is listed above; the full backend/frontend checks are not claimed. No documentation change is required for restoring the accepted document text contract.

From Codex

@github-actions github-actions Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 23, 2026
@crazywoola
crazywoola added this pull request to the merge queue Oct 30, 2026
Merged via the queue into langgenius:main with commit 949e5c2 Oct 30, 2026
36 checks passed
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node.js SDK rejects document text longer than 10,000 characters before sending a request

2 participants