jackwener/OpenCLI · error · CommandExecutionError

Twitter followers interceptor returned malformed responses

Error message

Twitter followers interceptor returned malformed responses

What it means

Inside consumeCaptured, the result of page.getInterceptedRequests() must be an array of captured requests. If the browser bridge returns anything else (null, undefined, an object), the interceptor contract is broken and the command cannot parse followers, so it throws CommandExecutionError. This indicates a bridge/interceptor plumbing problem, not a Twitter-side issue.

Source

Thrown at clis/twitter/followers.js:158

        }
        catch {
            throw new TimeoutError('twitter followers API capture', CAPTURE_TIMEOUT_SECONDS, 'No Followers response was observed after opening the followers list.');
        }
        const currentPath = unwrapBrowserResult(await page.evaluate('() => window.location.pathname'));
        if (typeof currentPath !== 'string' || !currentPath.toLowerCase().endsWith('/followers')) {
            throw new CommandExecutionError('SPA navigation to Twitter followers failed');
        }

        const allFollowers = [];
        const seen = new Set();
        let cursor = null;
        let lastRawResponse = null;
        let pages = 0;

        const consumeCaptured = async () => {
            const requests = await page.getInterceptedRequests();
            if (!Array.isArray(requests)) {
                throw new CommandExecutionError('Twitter followers interceptor returned malformed responses');
            }
            for (const request of requests) {
                const { data, users, nextCursor } = parseFollowers(request);
                const graphqlError = twitterGraphqlError(data);
                if (graphqlError)
                    throw new CommandExecutionError(graphqlError);
                lastRawResponse = data;
                for (const user of users) {
                    if (!seen.has(user.screen_name)) {
                        seen.add(user.screen_name);
                        allFollowers.push(user);
                    }
                }
                cursor = nextCursor;
            }
        };

        await consumeCaptured();

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Ensure the opencli bridge and CLI versions match (upgrade both together)
  2. Verify installInterceptor('/Followers?') succeeded before consuming
  3. Unwrap the bridge result if getInterceptedRequests returns { session, data } style wrappers
  4. Report the raw return value to the library maintainers if it persists

Example fix

// before
const requests = await page.getInterceptedRequests();
if (!Array.isArray(requests)) throw ...
// after (unwrap bridge envelope first)
const raw = unwrapBrowserResult(await page.getInterceptedRequests());
const requests = Array.isArray(raw) ? raw : (Array.isArray(raw?.data) ? raw.data : []);
Defensive patterns

Strategy: type-guard

Validate before calling

null

Type guard

function isCapturedRequests(v) {
  return Array.isArray(v);
}
// usage: if (!isCapturedRequests(await page.getInterceptedRequests())) fail fast;

Try / catch

try {
  const rows = await opencli.twitter.followers(user, { limit });
} catch (err) {
  if (err.message.includes('interceptor returned malformed responses')) {
    // bridge/interceptor contract issue: reinstall interceptor, align versions, or retry
    return opencli.twitter.followers(user, { limit });
  } else throw err;
}

Prevention

When it happens

Trigger: page.getInterceptedRequests() returns a non-Array — the interceptor was never installed, the browser bridge/session changed shape (e.g. unwrapping mismatch in unwrapBrowserResult), or a library version mismatch between the page bridge and the CLI.

Common situations: Upgrading one half of the opencli bridge but not the other; running against a custom/unofficial browser backend whose getInterceptedRequests returns an object wrapper; interceptor installation failed silently earlier.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/4981620801ca06d3. Report an issue: GitHub.