can1357/oh-my-pi · error

Invalid credential id: ${value}

Error message

Invalid credential id: ${value}

What it means

parsePositiveCredential converts the `--credential` value to a number and requires it to be a safe integer >= 1. This error is thrown for non-numeric text, floats, NaN, values above Number.MAX_SAFE_INTEGER, or zero/negative ids.

Source

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

		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;
	let archiveExisting = false;
	let credentialId: number | undefined;
	for (let index = 0; index < tokens.length; index++) {
		const token = tokens[index]!;
		switch (token) {
			case "--path":

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass the numeric credential id as listed by the credentials listing command.
  2. List available credentials to find the correct positive integer id.
  3. Remove stray characters (spaces, commas, units) from the value.
  4. Use id 1 or higher — ids are 1-indexed.

Example fix

// before
/security plan --credential prod-key
// after
/security plan --credential 3
Defensive patterns

Strategy: validation

Validate before calling

const id = Number(raw);
if (!Number.isSafeInteger(id) || id < 1) throw new Error(`Invalid credential id: ${raw}`);

Type guard

const isPositiveCredential = (v: string): boolean => {
  const n = Number(v);
  return Number.isSafeInteger(n) && n >= 1;
};

Try / catch

try {
  const { credentialId } = parsePlanOptions(rest);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("Invalid credential id")) {
    console.error(`${err.message} — run /security credentials to list ids`);
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: `/security plan --credential abc`, `--credential 0`, `--credential -1`, or `--credential 1.5`.

Common situations: Typing a credential name instead of its numeric id; off-by-one copying from a table starting at 0; locale-formatted numbers with commas.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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