Skip to content

Feishu docx block ordering is incorrect after docx.document.convert #40807

@TaoXieSZ

Description

@TaoXieSZ

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

  1. Convert structured markdown (containing a top-level heading, body paragraph, secondary headings, and ordered/bullet list items) with Feishu docx.document.convert.
  2. Insert the returned blocks into a new Feishu docx document using the plugin write/append path.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions