{"record":{"id":"3ea06280cddb481a","repo":"can1357/oh-my-pi","slug":"flag-requires-a-value","errorCode":null,"errorMessage":"${flag} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/slash-commands/helpers/security.ts","lineNumber":51,"sourceCode":"\t\"wont_fix\",\n]);\n\nfunction coordinatorFor(runtime: SlashCommandRuntime) {\n\treturn getSecurityCoordinator({\n\t\tcwd: runtime.cwd,\n\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;","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/slash-commands/helpers/security.ts#L33-L69","documentation":"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`.","triggerScenarios":"`/security plan --credential` with nothing after it, or `/security plan --credential --exclude x` where the next token is another flag.","commonSituations":"Forgotten value after the flag; copy-pasting a command with the value dropped; negative-looking values like `--5` being treated as flags.","solutions":["Provide the value directly after the flag: `--credential 3`.","Quote values that could begin with `--` if the parser supports it.","Re-read the command usage and ensure every flag has its argument.","Check command help output for the expected flag order."],"exampleFix":"// before\n/security plan --credential\n// after\n/security plan --credential 2","handlingStrategy":"type-guard","validationCode":"if (tokens.length <= index + 1 || tokens[index + 1].startsWith(\"--\")) {\n  throw new Error(`${flag} requires a value`);\n}","typeGuard":"const hasValue = (tokens: readonly string[], i: number): boolean => i < tokens.length && !tokens[i].startsWith(\"--\");","tryCatchPattern":"try {\n  options = parsePlanOptions(rest);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"requires a value\")) {\n    printUsage(err.message);\n    return;\n  }\n  throw err;\n}","preventionTips":["Always type a value immediately after value-taking flags.","Read the command help before composing flags.","Quote values that might look like flags."],"tags":["cli","argument-parsing","usage"],"backgroundTag":"missing-argument-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}