Yeachan-Heo/oh-my-codex · error · Error

`dry_run` must be boolean

Error message

`dry_run` must be boolean

What it means

The config's dry_run field must be strictly boolean (true/false). 1/0, "true"/"false" strings, or a missing key (undefined) are rejected.

Source

Thrown at src/cli/tmux-hook.ts:153

  const maxInjections = parsed.max_injections_per_session;
  if (typeof cooldown !== 'number' || cooldown < 0 || !Number.isFinite(cooldown)) {
    throw new Error('`cooldown_ms` must be a non-negative number');
  }
  if (typeof maxInjections !== 'number' || maxInjections < 1 || !Number.isFinite(maxInjections)) {
    throw new Error('`max_injections_per_session` must be >= 1');
  }

  const promptTemplate = parsed.prompt_template;
  const marker = parsed.marker;
  if (typeof promptTemplate !== 'string' || promptTemplate.trim() === '') {
    throw new Error('`prompt_template` must be a non-empty string');
  }
  if (typeof marker !== 'string' || marker.trim() === '') {
    throw new Error('`marker` must be a non-empty string');
  }

  if (parsed.dry_run !== true && parsed.dry_run !== false) {
    throw new Error('`dry_run` must be boolean');
  }
  if (parsed.log_level !== 'error' && parsed.log_level !== 'info' && parsed.log_level !== 'debug') {
    throw new Error('`log_level` must be one of: error, info, debug');
  }
  if (parsed.skip_if_scrolling !== undefined && parsed.skip_if_scrolling !== true && parsed.skip_if_scrolling !== false) {
    throw new Error('`skip_if_scrolling` must be boolean');
  }

  return {
    enabled: parsed.enabled,
    target: { type: targetObj.type, value: targetObj.value },
    allowed_modes: allowedModes,
    cooldown_ms: cooldown,
    max_injections_per_session: maxInjections,
    prompt_template: promptTemplate,
    marker,
    dry_run: parsed.dry_run,
    log_level: parsed.log_level,

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Set "dry_run": true or false explicitly (unquoted boolean)
  2. If templating, coerce with === 'true' style logic before serializing
  3. Use omx tmux-hook init to regenerate defaults

Example fix

// before
{"dry_run": "true"}
// after
{"dry_run": true}
Defensive patterns

Strategy: type-guard

Validate before calling

if (cfg.dry_run !== true && cfg.dry_run !== false) throw new Error('dry_run must be boolean');

Type guard

const isBool = (v: unknown): v is boolean => v === true || v === false;

Try / catch

try { await loadConfig(); } catch (e) { if (e instanceof Error && e.message.includes('dry_run')) fixDryRun(); }

Prevention

When it happens

Trigger: "dry_run": 1, "dry_run": "true", or omitting the key (it is required, not optional).

Common situations: Users assuming dry_run defaults to false when omitted; env-templated configs producing strings.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/064619956eec37e7. Report an issue: GitHub.