combine_record_xml (49/19) wraps <recorditem> in split CDATA, truncating Channels (<finderFeed>) and dropping subsequent messages on official WeChat

Open Beginner friendly
#908 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust, xml
Domain
api, backend

Research direction

Start in packages/native-client-rust/crates/wechat-protocol/src/forward.rs at combine_record_xml, then read push_tag and the merged-forward.xml fixture. Change the recorditem serialization as suggested and check whether XML escaping still fits MAX_FORWARD_APP_MSG_XML_BYTES. Done when a combined record preserves a Channels item and all following messages; add or update a focused regression test for content containing ]]>.

Written by the indexing model from the issue text.

Description

Summary

When combine-forwarding (mode="combine", 49/19) a batch that includes a WeChat Channels video (49/51, <finderFeed>) followed by additional messages, official WeChat mobile clients (observed on iOS):

  1. Render the Channels item as a blank grey card with only the Channels butterfly icon (missing cover, title, and media metadata), and
  2. Silently drop every message after the Channels item from the combined chat history.

Meanwhile, agent-wechat's own forwarded.rs reader still displays all items (including messages after the Channels item), because roxmltree concatenates adjacent split CDATA nodes whereas official WeChat's <recorditem> parser does not.

Root Cause

In packages/native-client-rust/crates/wechat-protocol/src/forward.rs (combine_record_xml, lines 675–677), <recorditem> is wrapped in CDATA via push_cdata:

out.push_str("<recorditem>");
push_cdata(&mut out, &record_info);
out.push_str("</recorditem>");

where push_cdata (lines 70–79) splits any inner ]]> into ]]]]><![CDATA[>:

while let Some(idx) = rest.find("]]>") {
    out.push_str(&rest[..idx]);
    out.push_str("]]]]><![CDATA[>");
    rest = &rest[idx + 3..];
}

In packages/native-client-rust/crates/wechat-core/src/forwards.rs (lines 1055–1102), serialize_record_info embeds raw child XML fragments verbatim into <recordinfo> — including <finderFeed> (49/51), <finderLive> (49/63), <weappinfo> (49/33, 49/36), and nested <recordxml><recordinfo>...</recordinfo></recordxml> (49/19).

In real WeChat 49/51 messages, <finderFeed> wraps nearly every sub-field (<objectId>, <username>, <nickname>, <desc>, <url>, <thumbUrl>, etc.) in <![CDATA[...]]>. When push_cdata wraps the outer <recorditem>, every inner ]]> becomes ]]]]><![CDATA[>.

Official WeChat's XML parser does not concatenate split CDATA sections inside <recorditem> and instead truncates at the very first ]]> inside <finderFeed>:

  • Items before <finderFeed> and the <dataitem datatype="22"> header (<sourcename>, <sourcetime>) precede <finderFeed>, so they survive (producing the blank grey Channels card with just the butterfly icon).
  • Everything after the first ]]> (the rest of <finderFeed> and all subsequent <dataitem> entries) is lost on official WeChat.

By contrast, official WeChat's own 49/19 wire format (see packages/native-client-rust/crates/wechat-core/tests/fixtures/merged-forward.xml) XML-escapes <recorditem> instead of wrapping it in <![CDATA[...]]>:

<recorditem>&lt;recordinfo&gt;&lt;datalist count=&quot;4&quot;&gt;...&lt;![CDATA[...]]&gt;...&lt;/datalist&gt;&lt;/recordinfo&gt;</recorditem>
Affected Types

Any combined 49/19 batch containing inner ]]> inside <recordinfo>, including:

  • 49/51 Channels video (<finderFeed>)
  • 49/63 Channels live (<finderLive>)
  • 49/33, 49/36 Mini Program (<weappinfo>, when containing CDATA)
  • 49/19 Nested chat history (<recordxml><recordinfo>...</recordinfo></recordxml>, when inner <datadesc> uses CDATA)
  • Plain text messages literally containing ]]>
Reproduction Steps
  1. Select 4 messages in a chat: [text_1, text_2, channels_video_49_51, text_4].
  2. Call POST /v1/accounts/{a}/forwards with "mode": "combine" and all 4 messageIds.
  3. Open the resulting 49/19 combined chat-history card in official WeChat (e.g. iOS):
    • text_1 and text_2 appear normally.
    • channels_video_49_51 appears as an empty grey card with only the Channels icon.
    • text_4 is completely missing.
  4. Reading the same committed message via agent-wechat (GET /v1/accounts/{a}/messages/{id}) shows all 4 entries (confirming roxmltree parsed the split CDATA while official WeChat truncated at the first ]]>).
Suggested Fix

In packages/native-client-rust/crates/wechat-protocol/src/forward.rs (combine_record_xml), encode <recorditem> as XML-escaped text matching official WeChat instead of CDATA:

push_tag(&mut out, "recorditem", &record_info);

(forwarded.rs and app_msg_echo_matches in wechat-core/src/forwards.rs already support XML-escaped <recorditem>.)

(Also worth checking in combine_record_xml whether MAX_FORWARD_APP_MSG_XML_BYTES headroom is still comfortable after XML-escaping </>/" inside <recorditem>.)

Dominant language
Rust
Stars
319
Forks
131
Avg merge
3h 14m
Merged PRs (30d)
349

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thisnick/agent-wechat

All issues in thisnick/agent-wechat

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.