jackwener/OpenCLI · error · CliError

FETCH_ERROR

FETCH_ERROR

Error message

Unexpected auth/token_info response

What it means

This FETCH_ERROR is thrown by the ONES token-info command (clis/ones/token-info.js) when the `auth/token_info` endpoint returns a payload whose `user` object is missing or lacks `uuid`. The library treats that as an unusable auth/session response and stops before listing teams.

Source

Thrown at clis/ones/token-info.js:19

import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import { onesFetchInPage } from './common.js';
cli({
    site: 'ones',
    name: 'token-info',
    access: 'read',
    description: 'ONES Project API — session detail (GET auth/token_info) via Chrome Bridge: user, teams, org',
    domain: 'ones.cn',
    strategy: Strategy.COOKIE,
    browser: true,
    navigateBefore: false,
    args: [],
    columns: ['uuid', 'name', 'email', 'teams', 'org_name'],
    func: async (page) => {
        const root = (await onesFetchInPage(page, 'auth/token_info'));
        const user = root.user && typeof root.user === 'object' ? root.user : null;
        if (!user?.uuid) {
            throw new CliError('FETCH_ERROR', 'Unexpected auth/token_info response', 'Try `opencli ones me -f json` or check ONES_* env vars.');
        }
        const teamRows = Array.isArray(root.teams) ? root.teams : [];
        const teamsHint = teamRows
            .map((t) => {
            const n = String(t.name ?? '').trim();
            const u = String(t.uuid ?? '').trim();
            if (n && u)
                return `${n} (${u})`;
            return u || n;
        })
            .filter(Boolean)
            .join(', ');
        const org = root.org && typeof root.org === 'object' ? root.org : null;
        return [
            {
                uuid: String(user.uuid),
                name: String(user.name ?? ''),
                email: String(user.email ?? ''),

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate / refresh the ONES token or cookies, then retry.
  2. Check ONES_* env vars (host, org) point at the correct instance.
  3. Run `opencli ones me -f json` to inspect the raw auth payload.
  4. Compare the response shape against the current ONES API docs for auth/token_info.

Example fix

// before
opencli ones token-info   // expired session
// after
opencli ones login        # refresh credentials, then
opencli ones token-info -f json
Defensive patterns

Strategy: try-catch

Validate before calling

const root = await rawTokenInfo();
if (!(root?.user?.uuid)) { console.error('Session invalid — re-login before running token-info.'); }

Type guard

function hasValidTokenInfo(root) { return !!root && typeof root === 'object' && root.user != null && typeof root.user === 'object' && typeof root.user.uuid === 'string'; }

Try / catch

try {
  const info = await opencli.ones.tokenInfo();
} catch (e) {
  if (e.code === 'FETCH_ERROR') {
    console.error('Auth/token_info unusable — refresh credentials, check ONES_* env vars.');
    await relogin();
  } else throw e;
}

Prevention

When it happens

Trigger: The token/cookie is expired or invalid so ONES returns an error body without user.uuid; a proxy or login page HTML is returned instead of JSON; ONES changes the token_info response shape.

Common situations: Long-lived sessions that silently expired; misconfigured ONES_* env vars pointing to the wrong org; corporate proxies intercepting the request; API version drift.

Related errors


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