jackwener/OpenCLI · error · CliError

FETCH_ERROR

FETCH_ERROR

Error message

Unexpected users/me response

What it means

The `opencli ones me` command fetches users/me and accepts either {user:{...}} or a flat {uuid,...} object. If the resolved object has no string `uuid`, it throws FETCH_ERROR. Like the sibling check in resolveOnesUserUuid, this is a response-shape guard: the HTTP call succeeded but the payload is not a recognizable current-user object.

Source

Thrown at clis/ones/me.js:19

import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import { onesFetchInPage } from './common.js';
cli({
    site: 'ones',
    name: 'me',
    access: 'read',
    description: 'ONES Project API — current user (GET users/me) via Chrome Bridge',
    domain: 'ones.cn',
    strategy: Strategy.COOKIE,
    browser: true,
    navigateBefore: false,
    args: [],
    columns: ['uuid', 'name', 'email', 'phone', 'status'],
    func: async (page) => {
        const data = (await onesFetchInPage(page, 'users/me'));
        const u = data.user && typeof data.user === 'object' ? data.user : data;
        if (!u || typeof u.uuid !== 'string') {
            throw new CliError('FETCH_ERROR', 'Unexpected users/me response', 'See raw JSON with: opencli ones me -f json');
        }
        return [
            {
                uuid: String(u.uuid),
                name: String(u.name ?? ''),
                email: String(u.email ?? ''),
                phone: String(u.phone ?? ''),
                status: u.status != null ? String(u.status) : '',
            },
        ];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open ONES in the controlled Chrome tab and log in, then retry the command.
  2. Run `opencli ones me -f json` to inspect the raw response and identify the actual shape.
  3. Verify ONES_BASE_URL is the correct deployment origin.
  4. If the schema genuinely differs, update/patch the CLI's users/me parsing for your build.

Example fix

// before: diagnosing
opencli ones me
// after: dump raw JSON to see the actual payload
opencli ones me -f json
Defensive patterns

Strategy: type-guard

Validate before calling

// sanity check before parsing users/me output yourself
const u = data?.user && typeof data.user === 'object' ? data.user : data;
if (typeof u?.uuid !== 'string') console.error('users/me returned an unexpected shape; run: opencli ones me -f json');

Type guard

function isCurrentUser(u) {
  const o = u?.user && typeof u.user === 'object' ? u.user : u;
  return typeof o?.uuid === 'string' && o.uuid.length > 0;
}

Try / catch

try {
  const me = await opencli.ones.me();
} catch (e) {
  if (e.code === 'FETCH_ERROR' && /Unexpected users\/me/.test(e.message)) {
    console.error('Session likely expired or schema differs; re-login in Chrome and inspect: opencli ones me -f json');
  } else throw e;
}

Prevention

When it happens

Trigger: Running `opencli ones me` when the users/me response is not the expected JSON — e.g. an HTML login page parsed as text, a session-expired error object without a uuid field, or a server build returning a differently nested user object.

Common situations: Chrome tab not logged in or session expired; ONES instance with a modified/newer users/me schema; wrong ONES_BASE_URL returning a redirect page instead of JSON.

Related errors


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