-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
Feishu docx block ordering is incorrect after docx.document.convert #40807
Description
Bug type
- Incorrect behavior (not a crash/regression, but wrong output)
Summary
When converting markdown to Feishu docx blocks via docx.document.convert and inserting the returned blocks into a new document, the block ordering can be incorrect. Headings, paragraphs, and list items appear in the wrong sequence — for example, ordered list items before their section heading, or body text before the title.
Steps to reproduce
- Convert structured markdown (containing a top-level heading, body paragraph, secondary headings, and ordered/bullet list items) with Feishu
docx.document.convert. - Insert the returned blocks into a new Feishu docx document using the plugin write/append path.
- Observe the resulting document structure.
Expected behavior
The document should preserve the intended heading/paragraph/list ordering from the source markdown.
Actual behavior
Blocks appear in an incorrect order — headings may appear after body text, and ordered list items may appear before their section heading.
Environment
- OS: OpenCloudOS 9.4
- Node: v22.22.0
- Channel: Feishu
Root cause
The insertion code does not rebuild the block tree using first_level_block_ids, children, and parent_id from the convert response. Instead it relies on the raw array order, which does not reflect the document's intended structure.