slopus/happy · error
Cannot resume historical Happy sessions through legacy accou
Error message
Cannot resume historical Happy sessions through legacy account credentials because ${credentialPath} is missing. What it means
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.
Source
Thrown at packages/happy-cli/src/resume/resolveHappySession.ts:92
function decryptBoxBundle(bundle: Uint8Array, recipientSecretKey: Uint8Array): Uint8Array | null {
if (bundle.length < 56) {
return null;
}
const ephemeralPublicKey = bundle.slice(0, 32);
const nonce = bundle.slice(32, 56);
const ciphertext = bundle.slice(56);
const decrypted = tweetnacl.box.open(ciphertext, nonce, ephemeralPublicKey, recipientSecretKey);
return decrypted ? new Uint8Array(decrypted) : null;
}
function readAgentCredentials() {
const credentialPath = getLocalHappyAgentCredentialPath();
const credentials = readLocalHappyAgentCredentials();
if (!credentials) {
throw new Error(
`Cannot resume historical Happy sessions through legacy account credentials because ${credentialPath} is missing.`,
);
}
return credentials;
}
function resolveSessionEncryption(session: RawSession, credentials: LocalHappyAgentCredentials): RecordEncryption {
if (session.dataEncryptionKey) {
const encrypted = decodeBase64(session.dataEncryptionKey);
const sessionKey = decryptBoxBundle(encrypted.slice(1), credentials.contentKeyPair.secretKey);
if (!sessionKey) {
throw new Error(`Failed to decrypt data key for Happy session ${session.id}`);
}
return {
key: sessionKey,
variant: 'dataKey',
};
}View on GitHub (pinned to b824cd0a46)
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.
Example fix
// before // credentials file missing -> throw // after $ happy auth # recreate ~/.happy/agent-credentials $ happy resume <session-id>
Defensive patterns
Strategy: validation
Validate before calling
import { getLocalHappyAgentCredentialPath, readLocalHappyAgentCredentials } from '...';
const creds = readLocalHappyAgentCredentials();
if (!creds) {
console.error(`Run 'happy auth' first — credentials missing at ${getLocalHappyAgentCredentialPath()}`);
process.exit(1);
} Try / catch
try {
await resolveHappySession(id);
} catch (err) {
if ((err as Error).message.includes('legacy account credentials')) {
// spawn or instruct the user to run `happy auth`, then retry
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to logout: ${error instanceof Error ? error.message :
- Failed to decrypt data key for Happy session ${session.id}
- Happy session lookup authentication expired for legacy accou
- Authentication failed or was cancelled
AI-assisted analysis of slopus/happy@b824cd0a46 (2026-08-31).
Data as JSON: /api/errors/7493c337bb057417.
Report an issue: GitHub.