fix(weixin): add missing iLink-App-Id and iLink-App-ClientVersion headers#2943
Conversation
📋 Review SummaryThis PR fixes a critical connectivity issue (#2908) by adding two required HTTP headers ( 🔍 General Feedback
🎯 Specific Feedback🟡 High
function buildClientVersion(version: string): number {
const parts = version.split('.').map((p) => parseInt(p, 10));
if (parts.some(p => isNaN(p))) {
throw new Error(`Invalid version format: ${version}`);
}
const major = parts[0] ?? 0;
const minor = parts[1] ?? 0;
const patch = parts[2] ?? 0;
return ((major & 0xff) << 16) | ((minor & 0xff) << 8) | (patch & 0xff);
}🟢 Medium
function buildHeaders(token?: string): Record<string, string> {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
'X-WECHAT-UIN': randomUin(),
// iLink Bot API required headers
'iLink-App-Id': 'bot',
'iLink-App-ClientVersion': String(buildClientVersion(ILINK_PROTOCOL_VERSION)),
};
// ... rest of function
}🔵 Low
✅ Highlights
|
…ders The iLink Bot API requires these headers for session authentication. Without them, getupdates returns errcode -14 (session timeout). The protocol version (2.0.0) is tracked independently from our channel version, matching the current official plugin's API compatibility level. Closes #2908
12c5053 to
928a957
Compare
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
…error output PR #2943 fixed headers in buildHeaders() but the login flow in waitForLogin() still used a hardcoded incomplete header object. Reuse the shared buildHeaders() so all endpoints send consistent iLink-App-Id and iLink-App-ClientVersion headers. Also wrap channel.connect() in startSingle() with a try/catch so configuration errors print a clean message instead of dumping the yargs help text and a stack trace.
…error output (#3044) PR #2943 fixed headers in buildHeaders() but the login flow in waitForLogin() still used a hardcoded incomplete header object. Reuse the shared buildHeaders() so all endpoints send consistent iLink-App-Id and iLink-App-ClientVersion headers. Also wrap channel.connect() in startSingle() with a try/catch so configuration errors print a clean message instead of dumping the yargs help text and a stack trace.
…error output (QwenLM#3044) PR QwenLM#2943 fixed headers in buildHeaders() but the login flow in waitForLogin() still used a hardcoded incomplete header object. Reuse the shared buildHeaders() so all endpoints send consistent iLink-App-Id and iLink-App-ClientVersion headers. Also wrap channel.connect() in startSingle() with a try/catch so configuration errors print a clean message instead of dumping the yargs help text and a stack trace.
fix(weixin): add missing iLink-App-Id and iLink-App-ClientVersion headers
…error output (QwenLM#3044) PR QwenLM#2943 fixed headers in buildHeaders() but the login flow in waitForLogin() still used a hardcoded incomplete header object. Reuse the shared buildHeaders() so all endpoints send consistent iLink-App-Id and iLink-App-ClientVersion headers. Also wrap channel.connect() in startSingle() with a try/catch so configuration errors print a clean message instead of dumping the yargs help text and a stack trace.
TLDR
Add two required HTTP headers (
iLink-App-IdandiLink-App-ClientVersion) to the WeChat channel's API requests. Without these, the iLink Bot API returnserrcode: -14(session timeout), making the WeChat channel unusable.Also aligns
base_info.channel_versionin the request body to use the same protocol version.Screenshots / Video Demo
N/A — no user-facing change beyond fixing the connection. The channel should now connect and poll successfully instead of immediately erroring out.
Dive Deeper
The iLink Bot API requires two headers for client identification:
iLink-App-Id: bot— identifies the caller as a bot clientiLink-App-ClientVersion— a uint32-encoded version (major<<16 | minor<<8 | patch)Our
buildHeaders()was missing both. The official Tencent WeChat plugin (@tencent-weixin/openclaw-weixin) sends these alongside thebase_info.channel_versionin the request body — they serve different purposes (gateway identification vs body payload).The protocol version (
2.1.3→131331) is tracked via a singleILINK_PROTOCOL_VERSIONconstant, used for both the header and body, matching the official plugin's current version.Reviewer Test Plan
npm run build && npm run bundlenode dist/cli.js channel configure-weixin(scan QR code)node dist/cli.js channel start my-weixinerrcode: -14Testing Matrix
Linked issues / bugs
Fixes #2908
Related to #2882