lobehub/lobehub · error · InvalidArgumentError

Invalid boolean value: ${value}

Error message

Invalid boolean value: ${value}

What it means

Thrown by parseBoolean when the --<flag> value (after trimming and lowercasing) is not one of the six accepted boolean strings: '1', 'true', 'yes' (for true) or '0', 'false', 'no' (for false). The CLI intentionally rejects ambiguous values like 'y', 'n', 'maybe', 'on', 'off' to avoid silent misinterpretation.

Source

Thrown at apps/cli/src/commands/eval.ts:96

    log.error(normalized.message);
  }

  process.exit(1);
};

const parseScore = (value: string) => {
  const score = Number(value);
  if (!Number.isFinite(score)) {
    throw new InvalidArgumentError(`Invalid score: ${value}`);
  }
  return score;
};

const parseBoolean = (value: string) => {
  const normalized = value.trim().toLowerCase();
  if (['1', 'true', 'yes'].includes(normalized)) return true;
  if (['0', 'false', 'no'].includes(normalized)) return false;
  throw new InvalidArgumentError(`Invalid boolean value: ${value}`);
};

const parseResultJson = (value: string) => {
  let parsed: unknown;
  try {
    parsed = JSON.parse(value);
  } catch {
    throw new InvalidArgumentError('Invalid JSON value for --result-json');
  }

  if (!isRecord(parsed) || Array.isArray(parsed)) {
    throw new InvalidArgumentError('--result-json must be a JSON object');
  }

  return parsed;
};

const parseJsonObject = (option: string) => (value: string) => {

View on GitHub (pinned to 10f24d7ade)

Solutions

  1. Use one of: 1, true, yes, 0, false, no (case-insensitive).
  2. Avoid shorthand: use 'yes' instead of 'y', 'no' instead of 'n'.
  3. If the value comes from a shell variable, normalize it: VAL=true && lh eval ... --flag "$VAL".

Example fix

// before:
// lh eval report --verified y --run-id run-123
// after:
// lh eval report --verified yes --run-id run-123
Defensive patterns

Strategy: validation

Validate before calling

const TRUE_VALUES = new Set(['1', 'true', 'yes']);
const FALSE_VALUES = new Set(['0', 'false', 'no']);
function parseBooleanStrict(value: string): boolean {
  const n = value.trim().toLowerCase();
  if (TRUE_VALUES.has(n)) return true;
  if (FALSE_VALUES.has(n)) return false;
  throw new Error(`Invalid boolean: ${value}. Use one of: 1, true, yes, 0, false, no`);
}

Type guard

function isAcceptedBoolean(value: string): boolean {
  const n = value.trim().toLowerCase();
  return ['1','true','yes','0','false','no'].includes(n);
}

Prevention

When it happens

Trigger: Running an eval command with a boolean flag value that isn't in the accepted set. Examples: --verified 'y', --verified 'on', --verified 'maybe', --verified 't', --verified '' (empty).

Common situations: 1) Using shorthand 'y'/'n' instead of 'yes'/'no'. 2) Using 'on'/'off' (common in other CLIs). 3) Using 't'/'f' or 'T'/'F'. 4) Empty string from an unset variable. 5) Non-English words.

Related errors


AI-assisted analysis of lobehub/lobehub@10f24d7ade (2026-08-12). Data as JSON: /api/errors/cc2c5fa686dd403a. Report an issue: GitHub.