can1357/oh-my-pi · error · CliUsageError
Invalid --max-time value: ${JSON.stringify(value)}. Expected
Error message
Invalid --max-time value: ${JSON.stringify(value)}. Expected a positive number of seconds or duration like "5s", "10m", "1h". What it means
parseMaxTimeSeconds (used by the --max-time flag setter in flag-tables.ts) accepts a positive number of seconds or a duration like 5s/10m/1h. Anything else — non-numeric text, zero, negative, NaN, or unsupported units — raises this CliUsageError before the command runs.
Source
Thrown at packages/coding-agent/src/cli/flag-tables.ts:102
const setResume: OptionalSetter = (result, value) => {
result.resume = value !== undefined ? value : true;
};
const MAX_TIME_DURATION_RE = /^(\d+(?:\.\d+)?)([smh])$/;
function maxTimeMultiplier(unit: string | undefined): number {
if (unit === "h") return 3600;
if (unit === "m") return 60;
return 1;
}
function parseMaxTimeSeconds(value: string): number {
const trimmed = value.trim();
const duration = MAX_TIME_DURATION_RE.exec(trimmed);
const seconds = duration ? Number(duration[1]) * maxTimeMultiplier(duration[2]) : Number(trimmed);
if (Number.isFinite(seconds) && seconds > 0) return seconds;
throw new CliUsageError(
`Invalid --max-time value: ${JSON.stringify(value)}. Expected a positive number of seconds or duration like "5s", "10m", "1h".`,
);
}
/**
* Setters for flags with string values. Most built-ins consume the next argv
* token even when it starts with `-`; flags listed in
* {@link EXTENSION_SHADOWABLE_STRING_FLAGS} use extension-style consumption so
* a registered boolean extension can shadow them before profile bootstrap.
*/
export const STRING_SETTERS: Record<string, StringSetter> = {
"--cwd": (result, value) => {
result.cwd = value;
},
"--config": (result, value) => {
result.config = [...(result.config ?? []), value];
},
"--add-dir": (result, value) => {View on GitHub (pinned to 9690622007)
Solutions
- Use a plain positive number of seconds: --max-time 30
- Or use a supported duration suffix: --max-time 5s, --max-time 10m, --max-time 1h (no space before the unit)
- Check the flag actually received the value (quote it: --max-time "10m") and the unit is a recognized multiplier
- Ensure the value is > 0; zero and negatives are rejected
Example fix
// before omp <cmd> --max-time 5min // after omp <cmd> --max-time 5m
Defensive patterns
Strategy: validation
Validate before calling
const MAX_TIME_RE = /^(\d+(?:\.\d+)?)([smh])?$/;
const MULT = { s: 1, m: 60, h: 3600 };
function assertMaxTime(v) {
const m = MAX_TIME_RE.exec(String(v).trim());
const s = m ? Number(m[1]) * MULT[m[2] ?? 's'] : Number(v);
if (!Number.isFinite(s) || s <= 0) throw new Error(`Invalid --max-time: ${v}`);
} Try / catch
try {
parse('--max-time', value);
} catch (e) {
if (e instanceof CliUsageError && e.message.includes('--max-time')) {
console.error('Use seconds (30) or a duration like 5s / 10m / 1h, greater than zero.');
} else throw e;
} Prevention
- Use plain seconds or the exact suffixes s/m/h with no space (`5s`, not `5 sec`)
- Never pass 0 or negative values
- Quote duration values in shell scripts so they arrive intact
When it happens
Trigger: `--max-time abc`, `--max-time 0`, `--max-time -5`, `--max-time 5x` (unknown unit), `--max-time 5 s` (space inside duration), or `--max-time ''` (empty string).
Common situations: Users assuming milliseconds (`--max-time 30000` is 30000 s, not 30 s — that parses but note units), writing `5sec` or `5min` which don't match the duration regex, or shells splitting `5s` and losing it so the flag receives an empty/garbage value.
Related errors
- Invalid --service-tier value: ${JSON.stringify(value)}. Expe
- Invalid --surface '${raw}'. Valid values: ${GALLERY_SURFACE_
- unknown file type: {value}
- invalid size: {value}
- 2
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/05d4347a5d3123e9.
Report an issue: GitHub.