{"record":{"id":"ad66f697450e5dd9","repo":"jackwener/OpenCLI","slug":"manus-whoami-failed-probe-detail","errorCode":null,"errorMessage":"Manus whoami failed: ${probe.detail}","messagePattern":"Manus whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/manus/auth.js","lineNumber":37,"sourceCode":"        return { kind: 'auth', detail: 'Manus /api/auth/session HTTP ' + r.status };\n      }\n      if (r.status === 503) {\n        return { kind: 'http', httpStatus: 503 };\n      }\n      if (!r.ok) return { kind: 'http', httpStatus: r.status };\n      const d = await r.json();\n      const u = d?.user || d;\n      if (!u || !(u.id || u.userId)) {\n        return { kind: 'auth', detail: 'Manus /api/auth/session 200 but no user' };\n      }\n      return { ok: true, user_id: String(u.id || u.userId), name: String(u.name || u.displayName || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('manus.im', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Manus /api/auth/session`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Manus whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Manus probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'manus',\n  domain: 'manus.im',\n  loginUrl: 'https://manus.im/login',\n  columns: ['user_id', 'name'],\n  verify: verifyManusIdentity,\n  poll: async (page) => {\n    if (!await hasManusSessionCookie(page)) {\n      throw new AuthRequiredError('manus.im', 'Waiting for Manus session cookies');\n    }\n    return verifyManusIdentity(page);\n  },\n});\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/manus/auth.js#L19-L55","documentation":"The in-page probe wraps its fetch of /api/auth/session in try/catch; any JavaScript exception (network failure, JSON parse error, CSP/CORS block, fetch undefined) is returned as kind:'exception' and this line rethrows it as CommandExecutionError with the original message in detail.","triggerScenarios":"The in-page fetch throws — network interruption, DNS failure, response not JSON (r.json() rejects), page navigating mid-evaluate causing execution-context destruction, a browser extension or CSP blocking fetch.","commonSituations":"Offline or flaky network while running manus commands; Manus frontend CSP changes blocking in-page fetch; aborted navigation causing evaluate context destruction; API returning HTML (e.g. error page) that fails JSON parsing; SSL/proxy interception errors.","solutions":["Check network connectivity and retry the command.","Open https://manus.im manually to confirm the site loads and the session endpoint works.","Inspect probe.detail in the error message for the underlying exception (e.g. 'Failed to fetch', JSON parse error) and address that cause.","Disable conflicting browser extensions or proxy/SSL interception for manus.im.","Update the CLI if Manus changed /api/auth/session to return non-JSON responses."],"exampleFix":"// before: evaluate loses context on navigation\nconst probe = await page.evaluate(script); // throws: Execution context destroyed\n// after: stabilize before probing\nawait page.goto('https://manus.im/', { waitUntil: 'domcontentloaded' });\nawait page.wait(3);\nconst probe = await page.evaluate(script);","handlingStrategy":"try-catch","validationCode":"// verify browser can reach the API before probing\nawait page.goto('https://manus.im/', { waitUntil: 'domcontentloaded' });\nif (!page.url().includes('manus.im')) throw new Error('navigation to manus.im failed');","typeGuard":"function isProbeException(probe) { return probe?.kind === 'exception'; }","tryCatchPattern":"try {\n  const identity = await manusWhoami();\n} catch (e) {\n  if (e.name === 'CommandExecutionError' && e.message.startsWith('Manus whoami failed:')) {\n    // detail after colon holds the root cause; log it and retry once after re-navigation\n    await page.reload({ waitUntil: 'domcontentloaded' });\n  } else throw e;\n}","preventionTips":["Wait for page load (domcontentloaded) before running in-page evaluates to avoid context destruction.","Log probe.detail — it contains the underlying exception (Failed to fetch, JSON parse, etc.).","Handle non-JSON responses (HTML error pages) before calling r.json().","Test for proxy/extension interference that blocks in-page fetch calls."],"tags":["network","fetch-failed","manus","browser-automation","command-execution"],"backgroundTag":"in-page-fetch-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}