Yeachan-Heo/oh-my-codex · error

Invalid ${source}: missing value for ${flag}

Error message

Invalid ${source}: missing value for ${flag}

What it means

A direct policy flag (approval/sandbox) in worker launch args expects a value, but the next token is missing, undefined, empty, or looks like another flag (starts with '-'). parseDirectPolicyValue rejects these as 'missing value'.

Source

Thrown at src/team/model-contract.ts:318

export function splitWorkerLaunchArgs(raw: string | undefined): string[] {
  return tokenizeWorkerLaunchArgs(raw).map((token) => token.value);
}

/** Serialize worker launch arguments for reversible environment transport. */
export function serializeTeamWorkerLaunchArgs(args: readonly string[]): string {
  return args.map((arg) => {
    if (arg.includes('\\')) return `'${arg.replace(/'/g, `'"'"'`)}'`;
    return `"${arg.replace(/"/g, '\\"')}"`;
  }).join(' ');
}

function parseDirectPolicyValue(
  value: string | undefined,
  flag: string,
  source: string,
): string {
  if (typeof value !== 'string') {
    throw teamWorkerLaunchArgsError(source, `missing value for ${flag}`);
  }
  const normalized = value.trim();
  if (normalized === '' || normalized.startsWith('-')) {
    throw teamWorkerLaunchArgsError(source, `missing value for ${flag}`);
  }
  return value;
}

function setDirectPolicyValue(
  existingValue: string | null,
  value: string,
  axis: PolicyAxis,
  source: string,
): string {
  if (existingValue !== null && existingValue !== value) {
    throw teamWorkerLaunchArgsError(source, `conflicting duplicate ${axis} policy`);
  }
  return value;

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Supply an explicit value: --approval <value>
  2. Use the = form if supported (--approval=<value>)
  3. Check that shell variables used as values are non-empty and don't start with '-'

Example fix

# before
export OMX_TEAM_WORKER_LAUNCH_ARGS='--sandbox'
# after
export OMX_TEAM_WORKER_LAUNCH_ARGS='--sandbox read-only'
Defensive patterns

Strategy: validation

Validate before calling

function flagHasValue(tokens: string[], i: number): boolean {
  const v = tokens[i + 1];
  return typeof v === 'string' && v.trim() !== '' && !v.trim().startsWith('-');
}

Prevention

When it happens

Trigger: Args ending with the flag (--approval), followed by another flag (--approval --sandbox), or followed by an empty string.

Common situations: Assuming a flag is boolean rather than value-taking, or a shell expansion swallowing the value ($EMPTY_VAR expanding to nothing).

Related errors


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