jackwener/OpenCLI · error · CommandExecutionError
Twitter article response payload is malformed
Error message
Twitter article response payload is malformed
What it means
After the in-page API call for TweetResultByRestId, the result must be either an array or a plain object. Anything else (undefined, null, string, number) means the page script failed to return a usable payload, so a CommandExecutionError 'Twitter article response payload is malformed' is thrown. This distinguishes a broken browser-side execution from an actual API error (handled by the httpStatus/error branches).
Source
Thrown at clis/twitter/article.js:246
else if (blockType === 'unordered-list-item') parts.push('- ' + text);
else if (blockType === 'ordered-list-item') {
orderedCounter++;
parts.push(orderedCounter + '. ' + text);
}
else if (blockType === 'code-block') parts.push('\`\`\`\\n' + text + '\\n\`\`\`');
else parts.push(text);
}
return [{
title,
author: screenName,
content: parts.join('\\n\\n') || legacy.full_text || '',
url: 'https://x.com/' + screenName + '/status/' + tweetId,
}];
}
`));
if (!Array.isArray(rawResult) && !isPlainObject(rawResult)) {
throw new CommandExecutionError('Twitter article response payload is malformed');
}
if (rawResult?.httpStatus) {
const message = describeTwitterApiError('TweetResultByRestId', rawResult.httpStatus);
if (rawResult.httpStatus === 401 || rawResult.httpStatus === 403) {
throw new AuthRequiredError('x.com', message);
}
throw new CommandExecutionError(message);
}
if (rawResult?.error) {
throw new CommandExecutionError(rawResult.error + (rawResult.hint ? ` (${rawResult.hint})` : ''));
}
if (!Array.isArray(rawResult)) {
throw new CommandExecutionError('Twitter article response payload is malformed');
}
return rawResult;
}
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry the command — often the page just wasn't ready
- Ensure a stable network connection and let the page load fully (the command waits ~3s; slow pages may need retry)
- Disable interfering browser extensions in the CLI's profile
- If persistent, update the adapter's injected TweetResultByRestId script to match current X page behavior
Defensive patterns
Strategy: type-guard
Type guard
function isPlainObject(v) { return v !== null && typeof v === 'object' && !Array.isArray(v); }
function isUsableTweetPayload(v) { return Array.isArray(v) || isPlainObject(v); } Try / catch
try {
await articleCmd({ tweetId });
} catch (err) {
if (err.message.includes('payload is malformed')) {
console.error('Browser-side script returned unusable data — retry or update adapter scripts');
} else throw err;
} Prevention
- Retry — the X page may not have been fully loaded
- Keep browser extensions from interfering with page scripts
- Update adapter injected scripts when X's front-end changes
- Ensure stable connectivity so evaluates are not interrupted
When it happens
Trigger: The page.evaluate script returns undefined or a primitive — e.g. the evaluate was interrupted, the injected script failed silently, or the browser wrapper returned a non-serializable result.
Common situations: X page not fully loaded so the injected script bailed, browser navigation/reload mid-evaluate, extension interference with page scripts, or adapter page scripts breaking after X front-end changes.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Bilibili ${label} API returned a malformed payload
- lichess user: Lichess user "${username}" returned empty payl
- LinkedIn Learning searchV2 returned malformed payload: missi
- LinkedIn Learning feedRecommendationGroups returned malforme
- Maimai search returned malformed API payload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/09ee7a83357d0e7a.
Report an issue: GitHub.