slopus/happy · error

Happy session ID is required: happy resume <session-id>

Error message

Happy session ID is required: happy resume <session-id>

What it means

parseResumeCommandArgs() validates arguments for `happy resume`. Resuming requires exactly one argument: the Happy session ID. With zero args it throws this usage error; with more than one it throws an 'unexpected arguments' error. It is an argument-validation failure, thrown before any session lookup happens.

Source

Thrown at packages/happy-cli/src/resume/handleResumeCommand.ts:31

    cwd: string;
    args: string[];
};

export type ResumeLaunchOptions = {
    claudeStartingMode?: 'local' | 'remote';
    startedBy?: 'daemon' | 'terminal';
};

export function parseResumeCommandArgs(args: string[]): { showHelp: boolean; sessionId: string } {
    if (args.includes('-h') || args.includes('--help')) {
        return {
            showHelp: true,
            sessionId: '',
        };
    }

    if (args.length === 0) {
        throw new Error('Happy session ID is required: happy resume <session-id>');
    }
    if (args.length > 1) {
        throw new Error(`Unexpected arguments for happy resume: ${args.slice(1).join(' ')}`);
    }

    return {
        showHelp: false,
        sessionId: args[0],
    };
}

function resolveFlavor(metadata: Metadata): 'codex' | 'claude' | null {
    if (metadata.flavor === 'codex' || metadata.codexThreadId) {
        return 'codex';
    }
    if (metadata.flavor === 'claude' || metadata.claudeSessionId) {
        return 'claude';
    }

View on GitHub (pinned to b824cd0a46)

Solutions

  1. Run `happy resume <session-id>` with the actual session ID (find it in `happy` session history/output)
  2. Check the help output (`happy resume` shows help on usage errors) for the exact syntax
  3. In scripts, verify the session ID variable is non-empty before invoking the command

Example fix

// before
execSync(`happy resume ${sessionId}`); // sessionId may be empty
// after
if (!sessionId) throw new Error('sessionId is required for happy resume');
execSync(`happy resume ${sessionId}`);
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(3); // after 'resume'
if (args.length !== 1) {
  console.error('Usage: happy resume <session-id>');
  process.exit(1);
}

Try / catch

try {
  const parsed = parseResumeCommandArgs(argv);
} catch (err) {
  if (err.message.startsWith('Happy session ID is required')) {
    showResumeHelp();
  } else throw err;
}

Prevention

When it happens

Trigger: Invoking `happy resume` with no arguments (args.length === 0), or with extra arguments (args.length > 1, e.g. flags pasted after the ID).

Common situations: Typing `happy resume` and forgetting the ID; shell history shortcut dropping the argument; scripting where the session-ID variable is empty; passing flags like `happy resume --latest` that are not parsed as the ID.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of slopus/happy@b824cd0a46 (2026-08-31). Data as JSON: /api/errors/0c573692fd1eea6a. Report an issue: GitHub.