{"record":{"id":"5555d4d647479685","repo":"slopus/happy","slug":"failed-to-load-happy-sessions-error-message","errorCode":null,"errorMessage":"Failed to load Happy sessions: ${error.message}","messagePattern":"Failed to load Happy sessions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/resume/resolveHappySession.ts","lineNumber":146,"sourceCode":"\n    return parseResumableMetadata(session.id, metadata);\n}\n\nasync function fetchSessions(credentials: LocalHappyAgentCredentials): Promise<RawSession[]> {\n    try {\n        const response = await axios.get(`${configuration.serverUrl}/v1/sessions`, {\n            headers: {\n                Authorization: `Bearer ${credentials.token}`,\n                'X-Happy-Client': `cli-coding-session/${configuration.currentCliVersion}`,\n            },\n        });\n        return (response.data as { sessions: RawSession[] }).sessions;\n    } catch (error) {\n        if (error instanceof AxiosError) {\n            if (error.response?.status === 401) {\n                throw new Error('Happy session lookup authentication expired for legacy account credentials.');\n            }\n            throw new Error(`Failed to load Happy sessions: ${error.message}`);\n        }\n        throw error;\n    }\n}\n\nexport async function resolveHappySession(sessionId: string): Promise<ResumableHappySession> {\n    const credentials = readAgentCredentials();\n    const sessions = await fetchSessions(credentials);\n    const matched = resolveSessionRecordByPrefix(sessions, sessionId);\n    return {\n        id: matched.id,\n        active: matched.active,\n        metadata: decryptSessionMetadata(matched, credentials),\n    };\n}\n\nexport async function resolveReconnectableSession(sessionId: string): Promise<ReconnectableHappySession> {\n    const credentials = readAgentCredentials();","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/resume/resolveHappySession.ts#L128-L164","documentation":"fetchSessions wraps its Axios API call; any non-401 Axios error (network failure, DNS error, 5xx, timeout, TLS problem) is rethrown as `Failed to load Happy sessions: <axios message>`. Non-Axios errors are rethrown untouched. It distinguishes transport/server problems from the dedicated 401 auth-expired error.","triggerScenarios":"Calling fetchSessions when the Happy API endpoint is unreachable (no network, DNS failure, wrong serverUrl), returns 500/502/503, times out, or TLS fails — any AxiosError with status !== 401.","commonSituations":"Laptop offline or behind a captive portal/VPN; corporate proxy or firewall blocking the endpoint; API outage; custom serverUrl misconfigured; DNS resolver issues.","solutions":["Read the wrapped axios message: check internet connectivity and whether the API host resolves/reachable (curl the serverUrl).","Check Happy service status / wait out a 5xx outage and retry.","Fix proxy/VPN/firewall settings if the endpoint is blocked; set HTTPS_PROXY if required.","Verify serverUrl configuration points at the correct Happy API endpoint."],"exampleFix":"// before\n$ happy resume <id>  // Failed to load Happy sessions: getaddrinfo api.example.com ENOTFOUND\n// after\n$ curl -I https://api.happy.com/health   # diagnose connectivity\n$ # fix VPN/DNS/proxy, or configure correct serverUrl, then retry","handlingStrategy":"retry","validationCode":"// Pre-flight connectivity check:\nconst ok = await fetch(serverUrl + '/health').then(r => r.ok).catch(() => false);\nif (!ok) { console.error('Happy API unreachable — check network/VPN'); process.exit(1); }","typeGuard":null,"tryCatchPattern":"try {\n  const session = await resolveHappySession(id);\n} catch (err) {\n  if ((err as Error).message.startsWith('Failed to load Happy sessions:')) {\n    // exponential-backoff retry loop for transient network/5xx; surface axios message\n  } else throw err;\n}","preventionTips":["Check connectivity/VPN/proxy before scripted resume operations.","Add exponential backoff retries for transient network errors.","Pin/verify serverUrl configuration; monitor API status for outages."],"tags":["network","api","axios","connectivity"],"backgroundTag":"api-request-failed","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}