slopus/happy · error

Unexpected arguments for happy resume: ${args.slice(1).join(

Error message

Unexpected arguments for happy resume: ${args.slice(1).join(' ')}

What it means

This error is thrown by parseResumeCommandArgs when `happy resume` is invoked with more than one positional argument. The command accepts exactly one argument — the session ID — and any extra trailing arguments make the invocation ambiguous, so the CLI refuses to run and echoes the offending arguments back.

Source

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

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';
    }
    return null;
}

View on GitHub (pinned to b824cd0a46)

Solutions

  1. Invoke with exactly one argument: `happy resume <session-id>`
  2. If you meant to pass flags to the underlying claude/codex process, they are not supported here — run `happy resume <session-id>` and use the spawned CLI's own flags inside it
  3. Quote the session ID if it contains characters your shell may split
  4. Run `happy resume` with no args or `--help` to see formatResumeHelp usage text

Example fix

// before
happy resume abc123 --dangerously-skip-permissions
// after
happy resume abc123
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

try {
  await handleResumeCommand(rawArgs);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Unexpected arguments for happy resume')) {
    console.error(e.message + '\n' + formatResumeHelp());
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `happy resume <session-id> extra-arg` — args.length > 1 after the 'resume' subcommand is stripped. E.g. pasting a session ID with trailing whitespace-split tokens, passing flags intended for the spawned CLI (claude/codex) directly to `happy resume`, or shell-completing into multiple IDs.

Common situations: Users copy a command from docs like `happy resume abc123 --resume` thinking flags pass through; shell history expansion or quoting mistakes split one ID into two tokens; muscle memory from `claude --resume` style syntax.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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