jackwener/OpenCLI · error · AuthRequiredError

${probe.detail}

Error message

${probe.detail}

What it means

CommandExecutionError raised when the bookmarkFoldersSlice GraphQL call returns an error payload. The context note 'account may not have folder access' reflects that bookmark folders are a gated Twitter feature (originally Blue/premium), so many accounts receive an authorization error even while logged in.

Source

Thrown at clis/12306/auth.js:40

      if (/login\\.html/.test(r.url)) {
        return { kind: 'auth', detail: '12306 initMy12306Api redirected to login' };
      }
      const t = await r.text();
      let d = null;
      try { d = JSON.parse(t); } catch {}
      if (!d || d.status === false || /未登录|登录超时|NotLogin/i.test(t)) {
        return { kind: 'auth', detail: '12306 initMy12306Api returned NotLogin' };
      }
      const userName = d.data?.user_name || d.data?.userName || d.user_name || '';
      if (!userName) {
        return { kind: 'auth', detail: '12306 initMy12306Api 200 but no user_name surface' };
      }
      return { ok: true, user_name: String(userName) };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('12306.cn', probe.detail);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`12306 whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected 12306 probe: ${JSON.stringify(probe)}`);
  return { user_name: probe.user_name };
}

registerSiteAuthCommands({
  site: '12306',
  domain: '12306.cn',
  loginUrl: 'https://kyfw.12306.cn/otn/resources/login.html',
  columns: ['user_name'],
  quickCheck: has12306SessionCookie,
  verify: verify12306Identity,
  poll: async (page) => {
    if (!await has12306SessionCookie(page)) {
      throw new AuthRequiredError('12306.cn', 'Waiting for 12306 tk auth cookie');
    }
    return verify12306Identity(page);
  },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm the account actually has bookmark-folder access (check x.com UI for folders under Bookmarks)
  2. Retry after a short pause to rule out transient 5xx/429
  3. Re-login to refresh the session and retry
  4. Update the CLI so resolveTwitterQueryId picks up the current GraphQL queryId
Defensive patterns

Strategy: fallback

Validate before calling

// Feature-gated: check account entitlement before calling
// (no local preflight possible beyond a successful login); detect via catch.

Try / catch

try {
  folders = await opencli('twitter bookmark-folders');
} catch (e) {
  if (/bookmarkFoldersSlice/.test(e.message)) {
    if (/403/.test(e.message)) folders = null; // account lacks folder access — degrade gracefully
    else throw e;
  }
}

Prevention

When it happens

Trigger: The authenticated account is not entitled to bookmark folders; the endpoint returns 403/404 for the feature; a stale queryId produces 404; transient 5xx from Twitter; rate limiting.

Common situations: Free accounts trying to use a premium-only feature; region/rollout gating where the feature isn't enabled yet; running an older CLI whose pinned/fetched queryId no longer matches the deployed GraphQL API.

Related errors


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