jackwener/OpenCLI · error · AuthRequiredError

Waiting for 12306 tk auth cookie

Error message

Waiting for 12306 tk auth cookie

What it means

CommandExecutionError thrown when `twitter bookmark` completed without an unconfirmed write (so no timeout ambiguity) but result.ok was false — the in-page script caught an exception (e.g. button not found, click rejected) and returned it as result.message. The remediation hint 'Nothing changed' tells the user no state was modified, so a retry is safe.

Source

Thrown at clis/12306/auth.js:55

      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. Read result.message in the error text to see the underlying in-page exception
  2. Open the tweet URL in the browser and verify the tweet exists and is bookmarkable
  3. Reload the page/session (re-login if needed) and retry the command
  4. If the button selector keeps failing after a reload, update or file an issue against the CLI — the UI testid likely changed
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the tweet is publicly viewable before bookmarking
const res = await fetch(tweetUrl, { method: 'HEAD' });
if (!res.ok) throw new Error(`Tweet unavailable: HTTP ${res.status}`);

Type guard

function isActionableFailure(r) { return r && typeof r === 'object' && r.ok === false && r.unconfirmed !== true; }

Try / catch

try {
  await opencli('twitter bookmark', url);
} catch (e) {
  if (/Nothing changed/.test(e.message)) {
    // safe to retry after checking the tweet exists and the page loads
    await reloadAndVerify(tweetUrl);
    await opencli('twitter bookmark', url);
  }
}

Prevention

When it happens

Trigger: The bookmark button wasn't found on the rendered page (page didn't finish loading, tweet deleted/protected, logged-out view), the click threw, or an unexpected dialog/overlay intercepted the action.

Common situations: Deleted or private/protected tweets; rate-limited or partially loaded page; Twitter UI change moving the bookmark button's data-testid; session in a weird logged-out state without triggering the ct0 check path.

Related errors


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