earendil-works/pi · error · AuthCommandError

--min-expiry must use a duration such as 30m or 1h

Error message

--min-expiry must use a duration such as 30m or 1h

What it means

Thrown when the value after --min-expiry does not match the duration pattern /^(\d+)(ms|s|m|h)$/: it must be an integer amount followed by exactly one unit of milliseconds, seconds, minutes, or hours.

Solutions

  1. Use forms like 30m, 1h, 45s, or 500ms
  2. Avoid decimals, compound units (1h30m), or missing units
  3. Do not leave --min-expiry without a following value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/cli/auth-command.ts:77 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/e264317cce7ab65a. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/cli/auth-command.ts:77

	if (!kind) {
		throw new AuthCommandError(
			`Unknown auth command "${args[1] ?? ""}". Use "${APP_NAME} auth print-api-key", "${APP_NAME} auth print-bearer-token", or "${APP_NAME} auth check".`,
		);
	}

	const commandArgs: string[] = [];
	let json = false;
	let credentials = false;
	let noRefresh = false;
	let minExpiryMs: number | undefined;
	for (let index = 2; index < args.length; index++) {
		const arg = args[index];
		if (arg === "--min-expiry") {
			if (kind !== "bearer_token")
				throw new AuthCommandError("--min-expiry is only supported by print-bearer-token");
			const value = args[++index];
			const match = value ? /^(\d+)(ms|s|m|h)$/iu.exec(value) : undefined;
			if (!match) throw new AuthCommandError("--min-expiry must use a duration such as 30m or 1h");
			const amount = Number(match[1]);
			const unit = match[2];
			minExpiryMs = amount * (unit === "ms" ? 1 : unit === "s" ? 1_000 : unit === "m" ? 60_000 : 3_600_000);
			continue;
		}
		if (arg === "--json" || arg === "--credentials" || arg === "--no-refresh") {
			if (kind !== "check") throw new AuthCommandError(`${arg} is only supported by auth check`);
			if (arg === "--json") json = true;
			else if (arg === "--credentials") credentials = true;
			else noRefresh = true;
			continue;
		}
		commandArgs.push(arg);
	}

	return minExpiryMs === undefined
		? { kind, args: commandArgs, json, credentials, noRefresh }
		: { kind, args: commandArgs, json, credentials, noRefresh, minExpiryMs };

View on GitHub (pinned to 4af9d21d3b)