can1357/oh-my-pi · error · Error
Invalid --state '${raw}'. Valid values: ${GALLERY_STATE_TOKE
Error message
Invalid --state '${raw}'. Valid values: ${GALLERY_STATE_TOKENS.join(", ")} What it means
parseGalleryStates validates the --state CLI flag for `omp gallery`. It looks each comma/whitespace-separated token up in GALLERY_STATE_ALIASES (case-insensitive, trimmed); any token not present in the alias table throws immediately so the user sees the full list of valid values instead of getting an empty/partial gallery.
Source
Thrown at packages/coding-agent/src/cli/gallery-cli.ts:85
for (const surface of GALLERY_SURFACES) requested.add(surface);
continue;
}
if (!GALLERY_SURFACES.includes(token as GallerySurface)) {
throw new Error(`Invalid --surface '${raw}'. Valid values: ${GALLERY_SURFACE_TOKENS.join(", ")}`);
}
requested.add(token as GallerySurface);
}
return GALLERY_SURFACES.filter(surface => requested.has(surface));
}
/** Normalize user-provided `--state` tokens to the internal gallery lifecycle states. */
export function parseGalleryStates(states: readonly string[] | undefined): GalleryState[] | undefined {
if (!states || states.length === 0) return undefined;
const parsed: GalleryState[] = [];
for (const raw of states) {
const state = GALLERY_STATE_ALIASES[raw.trim().toLowerCase()];
if (!state) {
throw new Error(`Invalid --state '${raw}'. Valid values: ${GALLERY_STATE_TOKENS.join(", ")}`);
}
if (!parsed.includes(state)) parsed.push(state);
}
return parsed;
}
export interface GalleryCommandArgs {
/** Render width in columns (defaults to terminal width, clamped). */
width?: number;
/** Restrict rendering to selected surface types (defaults to all). */
surfaces?: GallerySurface[];
/** Restrict to a single tool name. */
tool?: string;
/** Restrict to a single composer shape. */
composer?: string;
/** Restrict to a single status-line segment. */
segment?: string;
/** Restrict to specific lifecycle states. */View on GitHub (pinned to 9690622007)
Solutions
- Run `omp gallery --help` (or read GALLERY_STATE_TOKENS in the error message) and use one of the listed tokens
- Fix the typo in the --state value; matching is case-insensitive so casing is fine but spelling must match an alias
- If a legitimate state is missing from the table, add it to GALLERY_STATE_ALIASES/GALLERY_STATE_TOKENS in gallery-cli.ts
Example fix
// before omp gallery --state archivd // after omp gallery --state archived
Defensive patterns
Strategy: validation
Validate before calling
const VALID = new Set(["current","archived","all"]); // GALLERY_STATE_TOKENS
const states = (raw ?? "").split(",").map(s => s.trim().toLowerCase());
if (states.some(s => !VALID.has(s))) throw new Error(`--state must be one of: ${[...VALID].join(", ")}`); Prevention
- Copy state tokens from --help output or GALLERY_STATE_TOKENS rather than typing from memory
- Pre-validate flag values in shell scripts before invoking the CLI
- Use shell completion / tab completion where available
When it happens
Trigger: Running `omp gallery --state <unknown>` with a token that is not in GALLERY_STATE_ALIASES — e.g. a typo like `--state archivd`, an unsupported synonym like `--state old`, or a value quoted with stray characters.
Common situations: Typing a state name from memory; copying flags from docs for a different version where the alias table changed; passing a value with extra punctuation or a non-lowercased variant that is genuinely not an alias.
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
- invalid {} argument: {}
- invalid Zero increment value: {}
- --agents must be a positive integer
- --trusted-extension requires a non-empty, non-flag value
- Invalid credential id: ${value}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/d1729911ea1159e7.
Report an issue: GitHub.