{"record":{"id":"4d2b8a3f22028e63","repo":"jackwener/OpenCLI","slug":"fetch-error-4d2b8a","errorCode":"FETCH_ERROR","errorMessage":"Unexpected users/me response","messagePattern":"Unexpected users/me response","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/ones/me.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: 'me',\n    access: 'read',\n    description: 'ONES Project API — current user (GET users/me) via Chrome Bridge',\n    domain: 'ones.cn',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    navigateBefore: false,\n    args: [],\n    columns: ['uuid', 'name', 'email', 'phone', 'status'],\n    func: async (page) => {\n        const data = (await onesFetchInPage(page, 'users/me'));\n        const u = data.user && typeof data.user === 'object' ? data.user : data;\n        if (!u || typeof u.uuid !== 'string') {\n            throw new CliError('FETCH_ERROR', 'Unexpected users/me response', 'See raw JSON with: opencli ones me -f json');\n        }\n        return [\n            {\n                uuid: String(u.uuid),\n                name: String(u.name ?? ''),\n                email: String(u.email ?? ''),\n                phone: String(u.phone ?? ''),\n                status: u.status != null ? String(u.status) : '',\n            },\n        ];\n    },\n});\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ones/me.js#L1-L32","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open ONES in the controlled Chrome tab and log in, then retry the command.","Run `opencli ones me -f json` to inspect the raw response and identify the actual shape.","Verify ONES_BASE_URL is the correct deployment origin.","If the schema genuinely differs, update/patch the CLI's users/me parsing for your build."],"exampleFix":"// before: diagnosing\nopencli ones me\n// after: dump raw JSON to see the actual payload\nopencli ones me -f json","handlingStrategy":"type-guard","validationCode":"// sanity check before parsing users/me output yourself\nconst u = data?.user && typeof data.user === 'object' ? data.user : data;\nif (typeof u?.uuid !== 'string') console.error('users/me returned an unexpected shape; run: opencli ones me -f json');","typeGuard":"function isCurrentUser(u) {\n  const o = u?.user && typeof u.user === 'object' ? u.user : u;\n  return typeof o?.uuid === 'string' && o.uuid.length > 0;\n}","tryCatchPattern":"try {\n  const me = await opencli.ones.me();\n} catch (e) {\n  if (e.code === 'FETCH_ERROR' && /Unexpected users\\/me/.test(e.message)) {\n    console.error('Session likely expired or schema differs; re-login in Chrome and inspect: opencli ones me -f json');\n  } else throw e;\n}","preventionTips":["Re-login to ONES in the controlled Chrome profile whenever you see this.","Use `opencli ones me -f json` as your session health check.","Verify ONES_BASE_URL returns JSON API responses, not redirect pages."],"tags":["ones","api","response-shape","authentication"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}