{"record":{"id":"161cbfddab4b998a","repo":"can1357/oh-my-pi","slug":"invalid-credential-id-value","errorCode":null,"errorMessage":"Invalid credential id: ${value}","messagePattern":"Invalid credential id: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/slash-commands/helpers/security.ts","lineNumber":57,"sourceCode":"\t\tsettings: runtime.settings,\n\t\tauthStorage: runtime.session.modelRegistry.authStorage,\n\t\tmodelRegistry: runtime.session.modelRegistry,\n\t\tactiveModel: runtime.session.model,\n\t\tsessionId: runtime.session.sessionId,\n\t\tagentId: runtime.session.getAgentId(),\n\t\tasyncJobManager: runtime.session.asyncJobManager,\n\t});\n}\n\nfunction requireToken(tokens: readonly string[], index: number, flag: string): string {\n\tconst value = tokens[index];\n\tif (!value || value.startsWith(\"--\")) throw new Error(`${flag} requires a value`);\n\treturn value;\n}\n\nfunction parsePositiveCredential(value: string): number {\n\tconst credentialId = Number(value);\n\tif (!Number.isSafeInteger(credentialId) || credentialId < 1) throw new Error(`Invalid credential id: ${value}`);\n\treturn credentialId;\n}\n\nfunction parsePlanOptions(rest: string): SecurityPlanCliOptions {\n\tconst tokens = parseCommandArgs(rest);\n\tconst includePaths: string[] = [];\n\tconst excludePaths: string[] = [];\n\tconst knowledgeBasePaths: string[] = [];\n\tlet kind: SecurityTargetRequest[\"kind\"] = \"repository\";\n\tlet baseRevision: string | undefined;\n\tlet headRevision: string | undefined;\n\tlet outputRoot: string | undefined;\n\tlet archiveExisting = false;\n\tlet credentialId: number | undefined;\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tconst token = tokens[index]!;\n\t\tswitch (token) {\n\t\t\tcase \"--path\":","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/slash-commands/helpers/security.ts#L39-L75","documentation":"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.","triggerScenarios":"`/security plan --credential abc`, `--credential 0`, `--credential -1`, or `--credential 1.5`.","commonSituations":"Typing a credential name instead of its numeric id; off-by-one copying from a table starting at 0; locale-formatted numbers with commas.","solutions":["Pass the numeric credential id as listed by the credentials listing command.","List available credentials to find the correct positive integer id.","Remove stray characters (spaces, commas, units) from the value.","Use id 1 or higher — ids are 1-indexed."],"exampleFix":"// before\n/security plan --credential prod-key\n// after\n/security plan --credential 3","handlingStrategy":"validation","validationCode":"const id = Number(raw);\nif (!Number.isSafeInteger(id) || id < 1) throw new Error(`Invalid credential id: ${raw}`);","typeGuard":"const isPositiveCredential = (v: string): boolean => {\n  const n = Number(v);\n  return Number.isSafeInteger(n) && n >= 1;\n};","tryCatchPattern":"try {\n  const { credentialId } = parsePlanOptions(rest);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Invalid credential id\")) {\n    console.error(`${err.message} — run /security credentials to list ids`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Look up numeric ids via the credentials listing, not names.","Remember ids are 1-indexed positive integers.","Strip whitespace and separators before passing values."],"tags":["cli","argument-parsing","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}