jackwener/OpenCLI · error · CommandExecutionError

Failed to add @ to list : no member_count in response

Error message

Failed to add @${username} to list ${listId}: no member_count in response

What it means

A CommandExecutionError from buildListAddMemberRow thrown when the add-member response contains neither a member_count nor any fatal GraphQL errors. The library uses member_count as its success signal, so an absent count means the mutation's outcome cannot be verified and the command is treated as failed.

Solutions

  1. Update this library to the latest version to pick up fixes for X's current response schema.
  2. Retry after a short wait — intermittent bot-check pages can produce empty payloads.
  3. Refresh session cookies; a logged-out or challenged session may receive degraded responses.
  4. Inspect the raw response (enable debug logging) to confirm what X actually returned and file an issue if the schema changed.

Example fix

// before: outdated library parses old schema
await listAddUser(page, { listId: '123456789', username: 'alice' });
// after
npm update <this-cli-package>  # then rerun the list-add command
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

function hasVerifiableMemberCount(r) {
  return r?.mc !== null && r?.mc !== undefined;
}

Try / catch

let lastErr;
for (let i = 0; i < 3; i++) {
  try { return await listAddUser(page, { listId, username }); }
  catch (e) {
    if (!/no member_count in response/.test(e.message)) throw e;
    lastErr = e;
    await sleep(5000 * (i + 1));
  }
}
throw lastErr;

Prevention

When it happens

Trigger: addResult.mc is null/undefined, fatalGraphqlErrors() returns empty, and HTTP was ok — X returned a success-shaped but structurally unexpected payload (schema drift or a non-mutation response).

Common situations: X changing the GraphQL response shape (version drift); hitting an unexpected page/redirect that returned HTML parsed as an empty payload; a bot-checked response stripped of data.

Related errors


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

Appendix: source

Thrown at clis/twitter/list-add-core.js:71

export function buildListAddMemberRow({ addResult, memberCountBefore, listId, username, userId }) {
    if (!addResult?.httpOk) {
        throw new CommandExecutionError(
            `Failed to add @${username} to list ${listId}: HTTP ${addResult?.status ?? 0}${addResult?.fetchError ? ' (' + addResult.fetchError + ')' : ''}${addResult?.raw ? ' — ' + addResult.raw : ''}`
        );
    }

    // X often returns a partial GraphQL error on `default_banner_media_results`
    // even on successful mutations. Treat only missing main data or non-decode
    // GraphQL errors as command failures.
    const hasMemberCount = addResult.mc !== null && addResult.mc !== undefined;
    const fatalErrors = fatalGraphqlErrors(addResult.errors);
    if (!hasMemberCount && fatalErrors.length) {
        const msg = fatalErrors.map((e) => e.message || JSON.stringify(e)).join('; ');
        throw new CommandExecutionError(`Failed to add @${username} to list ${listId}: ${msg.slice(0, 300)}`);
    }
    if (!hasMemberCount) {
        throw new CommandExecutionError(`Failed to add @${username} to list ${listId}: no member_count in response`);
    }

    const memberCountAfter = Number(addResult.mc);
    if (!Number.isFinite(memberCountAfter)) {
        throw new CommandExecutionError(`Failed to add @${username} to list ${listId}: invalid member_count in response`);
    }

    if (memberCountAfter < memberCountBefore) {
        throw new CommandExecutionError(
            `Failed to add @${username} to list ${listId}: member_count decreased unexpectedly (${memberCountBefore} → ${memberCountAfter})`
        );
    }

    const countIncreased = memberCountAfter > memberCountBefore;
    const noop = !countIncreased;
    if (noop && addResult.isMember !== true) {
        throw new CommandExecutionError(
            `Failed to add @${username} to list ${listId}: member_count unchanged and membership was not confirmed`

View on GitHub (pinned to 49907e53dc)