jackwener/OpenCLI · error · AuthRequiredError

weibo.com

Error message

weibo.com

What it means

getSelfUid resolves the logged-in user's uid from the Vue store or a config API; if both fail it throws AuthRequiredError('weibo.com'), meaning the tool cannot determine your Weibo identity and you must log in. The message is just the domain 'weibo.com'.

Source

Thrown at clis/weibo/utils.js:58

      const uid = store?.state?.config?.config?.uid;
      if (uid) return String(uid);
      return null;
    })()
  `));
    if (uid)
        return uid;
    // Fallback: config API
    const config = unwrapEvaluateResult(await page.evaluate(`
    (async () => {
      const resp = await fetch('/ajax/config/get_config', {credentials: 'include'});
      if (!resp.ok) return null;
      const data = await resp.json();
      return data.ok && data.data?.uid ? String(data.data.uid) : null;
    })()
  `));
    if (config)
        return config;
    throw new AuthRequiredError('weibo.com');
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to weibo.com in the automated browser session and retry.
  2. Verify cookies are valid (visit weibo.com and confirm you see your profile).
  3. Update the CLI if Weibo changed the config API response shape.
  4. Ensure the automation targets the same profile where you logged in.

Example fix

// before
const config = unwrapEvaluateResult(await page.evaluate(`...config api...`));
if (config) return config;
// after
const config = unwrapEvaluateResult(await page.evaluate(`...config api...`));
if (!config) throw new AuthRequiredError('weibo.com', 'Open weibo.com and log in, then retry.');
return config;
Defensive patterns

Strategy: try-catch

Validate before calling

const uid = await getSelfUidSafe(page);
if (!uid) throw new Error('Run the weibo login flow before commands needing a uid');

Type guard

function isAuthedConfig(d) {
  return d !== null && typeof d === 'object' && 'ok' in d && d.ok === true && !!d.data?.uid;
}

Try / catch

try {
  await weiboCommand.run(args);
} catch (err) {
  if (err instanceof AuthRequiredError) {
    console.error('Not logged in to weibo.com — run login, then retry');
  } else throw err;
}

Prevention

When it happens

Trigger: Running any weibo command that needs the account uid when neither the page's Vue store nor the config API (data.ok && data.data?.uid) yields a uid.

Common situations: Not logged in at all; logged into a different browser/profile than the automation; session cookies expired; Weibo API returned ok:false or omitted data.uid after a schema change.

Related errors


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