{"record":{"id":"7493c337bb057417","repo":"slopus/happy","slug":"cannot-resume-historical-happy-sessions-through-le","errorCode":null,"errorMessage":"Cannot resume historical Happy sessions through legacy account credentials because ${credentialPath} is missing.","messagePattern":"Cannot resume historical Happy sessions through legacy account credentials because (.+?) is missing\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/resume/resolveHappySession.ts","lineNumber":92,"sourceCode":"\nfunction decryptBoxBundle(bundle: Uint8Array, recipientSecretKey: Uint8Array): Uint8Array | null {\n    if (bundle.length < 56) {\n        return null;\n    }\n\n    const ephemeralPublicKey = bundle.slice(0, 32);\n    const nonce = bundle.slice(32, 56);\n    const ciphertext = bundle.slice(56);\n    const decrypted = tweetnacl.box.open(ciphertext, nonce, ephemeralPublicKey, recipientSecretKey);\n\n    return decrypted ? new Uint8Array(decrypted) : null;\n}\n\nfunction readAgentCredentials() {\n    const credentialPath = getLocalHappyAgentCredentialPath();\n    const credentials = readLocalHappyAgentCredentials();\n    if (!credentials) {\n        throw new Error(\n            `Cannot resume historical Happy sessions through legacy account credentials because ${credentialPath} is missing.`,\n        );\n    }\n    return credentials;\n}\n\nfunction resolveSessionEncryption(session: RawSession, credentials: LocalHappyAgentCredentials): RecordEncryption {\n    if (session.dataEncryptionKey) {\n        const encrypted = decodeBase64(session.dataEncryptionKey);\n        const sessionKey = decryptBoxBundle(encrypted.slice(1), credentials.contentKeyPair.secretKey);\n        if (!sessionKey) {\n            throw new Error(`Failed to decrypt data key for Happy session ${session.id}`);\n        }\n        return {\n            key: sessionKey,\n            variant: 'dataKey',\n        };\n    }","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/resume/resolveHappySession.ts#L74-L110","documentation":"readAgentCredentials loads legacy account credentials from the local Happy agent credential file to authenticate historical session lookup. If readLocalHappyAgentCredentials() returns null — the file at getLocalHappyAgentCredentialPath() is missing or unreadable — it throws this error naming the missing path. Historical (legacy) sessions cannot be decrypted/looked up without those account credentials.","triggerScenarios":"Running `happy resume <session-id>` on a machine where ~/.happy (or equivalent) has no agent credentials file; fresh OS install or new machine without `happy auth` login; HOME changed so the path resolves elsewhere; credentials file manually deleted.","commonSituations":"Moving to a new laptop; running inside a fresh Docker container; CI environments where the home directory is not persisted; switching users so the credential path differs.","solutions":["Run the Happy auth/login flow on this machine to recreate the agent credentials file.","Check that the file named in the error exists and is readable (ls -l <path>, permissions/ownership).","Ensure HOME (or the relevant env var) points to the profile that holds the credentials.","Copy the credentials file from the machine where the session was created if re-login is not possible."],"exampleFix":"// before\n// credentials file missing -> throw\n// after\n$ happy auth        # recreate ~/.happy/agent-credentials\n$ happy resume <session-id>","handlingStrategy":"validation","validationCode":"import { getLocalHappyAgentCredentialPath, readLocalHappyAgentCredentials } from '...';\nconst creds = readLocalHappyAgentCredentials();\nif (!creds) {\n  console.error(`Run 'happy auth' first — credentials missing at ${getLocalHappyAgentCredentialPath()}`);\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await resolveHappySession(id);\n} catch (err) {\n  if ((err as Error).message.includes('legacy account credentials')) {\n    // spawn or instruct the user to run `happy auth`, then retry\n  } else throw err;\n}","preventionTips":["Run the auth flow on every new machine/container before resuming sessions.","Persist ~/.happy (credentials dir) in dev containers/CI via volumes or secrets.","Don't delete or manually edit the agent credentials file.","Keep HOME consistent so the credential path resolves to the same profile."],"tags":["credentials","file-not-found","auth"],"backgroundTag":"missing-credentials-file","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}