can1357/oh-my-pi · error

${flag} requires a value

Error message

${flag} requires a value

What it means

requireToken reads the next slash-command token as a flag's value. It throws when the token is missing (end of input) or starts with `--` (i.e. the user typed another flag where a value was expected), for flags like `--credential`.

Source

Thrown at packages/coding-agent/src/slash-commands/helpers/security.ts:51

	"wont_fix",
]);

function coordinatorFor(runtime: SlashCommandRuntime) {
	return getSecurityCoordinator({
		cwd: runtime.cwd,
		settings: runtime.settings,
		authStorage: runtime.session.modelRegistry.authStorage,
		modelRegistry: runtime.session.modelRegistry,
		activeModel: runtime.session.model,
		sessionId: runtime.session.sessionId,
		agentId: runtime.session.getAgentId(),
		asyncJobManager: runtime.session.asyncJobManager,
	});
}

function requireToken(tokens: readonly string[], index: number, flag: string): string {
	const value = tokens[index];
	if (!value || value.startsWith("--")) throw new Error(`${flag} requires a value`);
	return value;
}

function parsePositiveCredential(value: string): number {
	const credentialId = Number(value);
	if (!Number.isSafeInteger(credentialId) || credentialId < 1) throw new Error(`Invalid credential id: ${value}`);
	return credentialId;
}

function parsePlanOptions(rest: string): SecurityPlanCliOptions {
	const tokens = parseCommandArgs(rest);
	const includePaths: string[] = [];
	const excludePaths: string[] = [];
	const knowledgeBasePaths: string[] = [];
	let kind: SecurityTargetRequest["kind"] = "repository";
	let baseRevision: string | undefined;
	let headRevision: string | undefined;
	let outputRoot: string | undefined;

View on GitHub (pinned to 9690622007)

Solutions

  1. Provide the value directly after the flag: `--credential 3`.
  2. Quote values that could begin with `--` if the parser supports it.
  3. Re-read the command usage and ensure every flag has its argument.
  4. Check command help output for the expected flag order.

Example fix

// before
/security plan --credential
// after
/security plan --credential 2
Defensive patterns

Strategy: type-guard

Validate before calling

if (tokens.length <= index + 1 || tokens[index + 1].startsWith("--")) {
  throw new Error(`${flag} requires a value`);
}

Type guard

const hasValue = (tokens: readonly string[], i: number): boolean => i < tokens.length && !tokens[i].startsWith("--");

Try / catch

try {
  options = parsePlanOptions(rest);
} catch (err) {
  if (err instanceof Error && err.message.includes("requires a value")) {
    printUsage(err.message);
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: `/security plan --credential` with nothing after it, or `/security plan --credential --exclude x` where the next token is another flag.

Common situations: Forgotten value after the flag; copy-pasting a command with the value dropped; negative-looking values like `--5` being treated as flags.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/3ea06280cddb481a. Report an issue: GitHub.