{"record":{"id":"f67706fac989910c","repo":"jackwener/OpenCLI","slug":"fetch-error-f67706","errorCode":"FETCH_ERROR","errorMessage":"ONES login response missing user.uuid or user.token","messagePattern":"ONES login response missing user\\.uuid or user\\.token","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/ones/login.js","lineNumber":57,"sourceCode":"            throw new CliError('CONFIG', 'Password required', 'Pass --password or set ONES_PASSWORD for non-interactive use.');\n        }\n        if (!email && !phone) {\n            throw new CliError('CONFIG', 'email or phone required', 'Pass --email or --phone (or set ONES_EMAIL / ONES_PHONE).');\n        }\n        getOnesBaseUrl();\n        const bodyObj = { password };\n        if (email)\n            bodyObj.email = email;\n        else\n            bodyObj.phone = phone;\n        const parsed = (await onesFetchInPage(page, 'auth/login', {\n            method: 'POST',\n            body: JSON.stringify(bodyObj),\n            auth: false,\n        }));\n        const user = parsed.user;\n        if (!user?.uuid || !user?.token) {\n            throw new CliError('FETCH_ERROR', 'ONES login response missing user.uuid or user.token', 'Your server build may differ from documented Project API.');\n        }\n        const uuid = String(user.uuid);\n        const token = String(user.token);\n        const name = String(user.name ?? '');\n        const em = String(user.email ?? '');\n        const base = getOnesBaseUrl();\n        console.error([\n            '',\n            '后续请求会优先使用当前 Chrome 会话 Cookie；若接口仍要求 Header，可 export：',\n            `  export ONES_BASE_URL=${JSON.stringify(base)}`,\n            `  export ONES_USER_ID=${JSON.stringify(uuid)}`,\n            `  export ONES_AUTH_TOKEN=${JSON.stringify(token)}`,\n            '',\n        ].join('\\n'));\n        return [\n            {\n                uuid,\n                name,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ones/login.js#L39-L75","documentation":"After POSTing credentials to the ONES login endpoint, the CLI expects the JSON body to contain user.uuid and user.token. If either is missing it throws FETCH_ERROR, meaning authentication may have succeeded at the HTTP layer but the response schema differs from the documented Project API. Without uuid/token the CLI cannot build the Ones-User-Id/Ones-Auth-Token headers used by later calls.","triggerScenarios":"Calling `opencli ones login` where the server replies with a body whose `user` object lacks `uuid` or `token` — e.g. a deployment whose login endpoint returns a different envelope, an error body with HTTP 200, or a newer ONES build that changed the login response shape.","commonSituations":"Self-hosted ONES instances on versions that diverge from the documented Project API; reverse proxies or SSO gateways that intercept the login POST and return their own payload; wrong ONES_BASE_URL hitting an HTML page instead of the API.","solutions":["Verify ONES_BASE_URL points at the correct ONES deployment origin (no proxy/SSO path).","Print the raw response (verbose logging) to see what the server actually returned.","Check your ONES server version against the documented Project API; if the schema changed, update the CLI or fall back to Cookie-based auth from a logged-in Chrome session.","Use the browser-session auth path instead: log into ONES in Chrome and export ONES_USER_ID / ONES_AUTH_TOKEN manually if your build exposes them."],"exampleFix":"// before: login against a proxied/SSO origin\nONES_BASE_URL=https://sso-gateway.corp.com opencli ones login ...\n// after: hit the ONES deployment origin directly\nONES_BASE_URL=https://your-team.ones.cn opencli ones login --email me@corp.com --password '...'","handlingStrategy":"type-guard","validationCode":"// after a manual login response, before using it\nconst user = parsed?.user;\nif (!user?.uuid || !user?.token) {\n  console.error('Login response lacks user.uuid/token — verify ONES_BASE_URL hits the real ONES API, not an SSO/proxy page.');\n}","typeGuard":"function hasLoginUser(p) {\n  const u = p?.user;\n  return typeof u === 'object' && u !== null &&\n    typeof u.uuid === 'string' && u.uuid.length > 0 &&\n    typeof u.token === 'string' && u.token.length > 0;\n}","tryCatchPattern":"try {\n  const me = await opencli.ones.login({ email, password });\n} catch (e) {\n  if (e.code === 'FETCH_ERROR' && /missing user\\.uuid/.test(e.message)) {\n    console.error('Server build mismatch — fall back to Cookie auth from a logged-in Chrome session.');\n  } else throw e;\n}","preventionTips":["Point ONES_BASE_URL directly at the ONES deployment origin, not an SSO/reverse-proxy gateway.","Check your ONES server version against the documented Project API before scripting login.","Print the raw response once to confirm the schema your build returns."],"tags":["ones","api","response-shape","schema-mismatch","authentication"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}