{"record":{"id":"5cb1e854d5e881ed","repo":"jackwener/OpenCLI","slug":"fetch-error-5cb1e8","errorCode":"FETCH_ERROR","errorMessage":"Unexpected auth/token_info response","messagePattern":"Unexpected auth/token_info response","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/ones/token-info.js","lineNumber":19,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CliError } from '@jackwener/opencli/errors';\nimport { onesFetchInPage } from './common.js';\ncli({\n    site: 'ones',\n    name: 'token-info',\n    access: 'read',\n    description: 'ONES Project API — session detail (GET auth/token_info) via Chrome Bridge: user, teams, org',\n    domain: 'ones.cn',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    navigateBefore: false,\n    args: [],\n    columns: ['uuid', 'name', 'email', 'teams', 'org_name'],\n    func: async (page) => {\n        const root = (await onesFetchInPage(page, 'auth/token_info'));\n        const user = root.user && typeof root.user === 'object' ? root.user : null;\n        if (!user?.uuid) {\n            throw new CliError('FETCH_ERROR', 'Unexpected auth/token_info response', 'Try `opencli ones me -f json` or check ONES_* env vars.');\n        }\n        const teamRows = Array.isArray(root.teams) ? root.teams : [];\n        const teamsHint = teamRows\n            .map((t) => {\n            const n = String(t.name ?? '').trim();\n            const u = String(t.uuid ?? '').trim();\n            if (n && u)\n                return `${n} (${u})`;\n            return u || n;\n        })\n            .filter(Boolean)\n            .join(', ');\n        const org = root.org && typeof root.org === 'object' ? root.org : null;\n        return [\n            {\n                uuid: String(user.uuid),\n                name: String(user.name ?? ''),\n                email: String(user.email ?? ''),","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ones/token-info.js#L1-L37","documentation":"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.","triggerScenarios":"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.","commonSituations":"Long-lived sessions that silently expired; misconfigured ONES_* env vars pointing to the wrong org; corporate proxies intercepting the request; API version drift.","solutions":["Re-authenticate / refresh the ONES token or cookies, then retry.","Check ONES_* env vars (host, org) point at the correct instance.","Run `opencli ones me -f json` to inspect the raw auth payload.","Compare the response shape against the current ONES API docs for auth/token_info."],"exampleFix":"// before\nopencli ones token-info   // expired session\n// after\nopencli ones login        # refresh credentials, then\nopencli ones token-info -f json","handlingStrategy":"try-catch","validationCode":"const root = await rawTokenInfo();\nif (!(root?.user?.uuid)) { console.error('Session invalid — re-login before running token-info.'); }","typeGuard":"function hasValidTokenInfo(root) { return !!root && typeof root === 'object' && root.user != null && typeof root.user === 'object' && typeof root.user.uuid === 'string'; }","tryCatchPattern":"try {\n  const info = await opencli.ones.tokenInfo();\n} catch (e) {\n  if (e.code === 'FETCH_ERROR') {\n    console.error('Auth/token_info unusable — refresh credentials, check ONES_* env vars.');\n    await relogin();\n  } else throw e;\n}","preventionTips":["Refresh ONES tokens/cookies proactively; sessions expire silently.","Verify ONES_* env vars point at the correct instance/org.","Probe auth with `opencli ones me -f json` after long idle periods.","Watch for proxy/login-page HTML instead of JSON in responses."],"tags":["auth","api","network","ones","response-parsing"],"backgroundTag":"invalid-auth-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}