{"record":{"id":"ba6820d0d9384394","repo":"jackwener/OpenCLI","slug":"unexpected-auth-me-result-json-stringify-r","errorCode":null,"errorMessage":"unexpected /auth/me result: ${JSON.stringify(r)}","messagePattern":"unexpected /auth/me result: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/slock/auth-verify.js","lineNumber":12,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { buildFetchSnippet } from './in-page.js';\nimport { SLOCK_DOMAIN, SLOCK_HOME_URL } from './shared.js';\n\n// site-auth's whoami sets navigateBefore:false, so verify owns navigation.\nexport async function verifySlockSession(page) {\n  await page.goto(SLOCK_HOME_URL);\n  const snippet = buildFetchSnippet({ method: 'GET', path: '/auth/me', serverScoped: false });\n  const r = await page.evaluate(`(async () => { ${snippet} })()`);\n  if (r && r.kind === 'auth') throw new AuthRequiredError(SLOCK_DOMAIN, r.detail);\n  // unknown / null envelope = contract drift; same typed class as dispatchEvaluateResult\n  if (!r || r.kind !== 'ok') throw new CommandExecutionError(`unexpected /auth/me result: ${JSON.stringify(r)}`);\n  const me = r.rows ?? {};\n  return {\n    id: me.id ?? null,\n    name: me.name ?? me.displayName ?? me.username ?? null,\n    email: me.email ?? null,\n  };\n}\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/auth-verify.js#L1-L20","documentation":"This CommandExecutionError is thrown when the /auth/me fetch returns null or an envelope whose kind is neither 'auth' nor 'ok' — i.e. contract drift between what the CLI expects and what the server/page returned. The message includes the JSON-serialized result for debugging.","triggerScenarios":"page.evaluate returns null (page navigated away mid-fetch, script error swallowed), or the server returns a new/unknown envelope kind (e.g. kind:'redirect', kind:'error') not covered by the snippet's contract.","commonSituations":"A Slock server version change altering the /auth/me envelope, a network/proxy erroring inside the in-page fetch, or the SPA redirecting /auth/me to an HTML page so parsing yields an unexpected shape.","solutions":["Read the JSON.stringify'd result in the message to see the actual envelope and identify the new shape.","Verify you are on a Slock server version compatible with this CLI; downgrade server or upgrade CLI to realign contracts.","Re-run after confirming network reachability of the API base from the page (proxy/VPN interference).","If kind is genuinely new, extend the snippet/dispatch logic to map it before calling verifySlockSession."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isOkEnvelope = (r) => r != null && typeof r === 'object' && r.kind === 'ok';","tryCatchPattern":"try {\n  const me = await verifySlockSession(page);\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('unexpected /auth/me result')) {\n    console.error('Server envelope drift — check CLI/server version compatibility:', e.message);\n  } else throw e;\n}","preventionTips":["Pin CLI and server versions that are known compatible.","Read the JSON in the error message to diagnose new envelope kinds.","Retry once after checking network/proxy health before escalating."],"tags":["api-contract","network","version-mismatch","unexpected-response"],"backgroundTag":"api-contract-drift","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}