Skip to content

Cherry-pick 4dc55ea88: fix(feishu): chunk large documents for write/append to avoid API 400 errors (#14402)#1472

Merged
alexey-pelykh merged 1 commit intomainfrom
cherry-pick/4dc55ea88-feishu-chunk-large-documents
Mar 15, 2026
Merged

Cherry-pick 4dc55ea88: fix(feishu): chunk large documents for write/append to avoid API 400 errors (#14402)#1472
alexey-pelykh merged 1 commit intomainfrom
cherry-pick/4dc55ea88-feishu-chunk-large-documents

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Cherry-pick of upstream openclaw/openclaw@4dc55ea88.

Original: fix(feishu): chunk large documents for write/append to avoid API 400 errors (openclaw#14402)

Part of #678.

Cherry-picked-from: 4dc55ea

…errors (openclaw#14402)

* fix(feishu): chunk large documents for write/append to avoid API 400 errors

The Feishu API limits documentBlockChildren.create to 50 blocks per
request and document.convert has content size limits for large markdown.

Previously, writeDoc and appendDoc would send the entire content in a
single API call, causing HTTP 400 errors for long documents.

This commit adds:
- splitMarkdownByHeadings(): splits markdown at # or ## headings
- chunkedConvertMarkdown(): converts each chunk independently
- chunkedInsertBlocks(): batches blocks into groups of ≤50

Both writeDoc and appendDoc now use the chunked helpers while
preserving backward compatibility for small documents. Image
processing correctly receives all inserted blocks across batches.

* fix(feishu): skip heading detection inside fenced code blocks

Addresses review feedback: splitMarkdownByHeadings() now tracks
fenced code blocks (``` or ~~~) and skips heading-based splitting
when inside one, preventing corruption of code block content.

* Feishu/Docx: add convert fallback chunking + tests

---------

Co-authored-by: lml2468 <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
(cherry picked from commit 4dc55ea)
@alexey-pelykh alexey-pelykh merged commit 5eb18ae into main Mar 15, 2026
7 checks passed
@alexey-pelykh alexey-pelykh deleted the cherry-pick/4dc55ea88-feishu-chunk-large-documents branch March 15, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants