{"record":{"id":"8733eaedbd77d6b7","repo":"paperclipai/paperclip","slug":"unknown-argument-args-index","errorCode":null,"errorMessage":"unknown argument: ${args[index] ?? \"\"}","messagePattern":"unknown argument: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/cli/eval-session.ts","lineNumber":53,"sourceCode":"import { evalProviderTransportOptions } from \"./eval-provider-runtime.js\";\n\ninterface EvalSessionCliOptions {\n  requestPath: string;\n  outputPath: string;\n}\n\nfunction argument(args: string[], name: string): string {\n  const index = args.indexOf(name);\n  const value = index < 0 ? undefined : args[index + 1];\n  if (!value || value.startsWith(\"--\")) throw new Error(`missing ${name}`);\n  return resolve(value);\n}\n\nexport function parseEvalSessionCliArgs(args: string[]): EvalSessionCliOptions {\n  const allowed = new Set([\"--request\", \"--output\"]);\n  for (let index = 0; index < args.length; index += 2) {\n    if (!allowed.has(args[index] ?? \"\")) {\n      throw new Error(`unknown argument: ${args[index] ?? \"\"}`);\n    }\n    if (args[index + 1] === undefined) throw new Error(`missing ${args[index]}`);\n  }\n  return {\n    requestPath: argument(args, \"--request\"),\n    outputPath: argument(args, \"--output\"),\n  };\n}\n\nasync function sha256(path: string): Promise<string> {\n  return createHash(\"sha256\").update(await readFile(path)).digest(\"hex\");\n}\n\nconst EVAL_RUNTIME_INSTRUCTIONS = [\n  \"# Paperclip direct live evaluation\",\n  \"\",\n  \"Use the provided Paperclip semantic tools to inspect and act on the assigned task.\",\n  \"Treat the seeded control-plane state as authoritative and keep every action within the requested scope.\",","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/src/cli/eval-session.ts#L35-L71","documentation":"parseEvalSessionCliArgs validates CLI flags in strict pairs: every even-indexed argument must be exactly '--request' or '--output'. This error is thrown when a flag outside that allowlist appears in argv, so unknown/misspelled flags fail fast instead of being silently ignored.","triggerScenarios":"Calling runEvalSessionCli (or the eval-session binary) with an argv array where args[i] (i even) is not '--request' or '--output' — e.g. typo'd flags like '--request-path', extra flags like '--verbose', or a stray positional value landing in an even slot.","commonSituations":"Typo in a flag name when invoking the CLI; copy-pasting invocation syntax from another tool; passing extra arguments (e.g. '--json') not supported by this entrypoint; shell word-splitting shifting a value into a flag position.","solutions":["Check the exact invocation: only '--request <path> --output <path>' are accepted, in flag/value pairs","Fix the typo or remove any unsupported flag from the command line","If a new flag is genuinely needed, add it to the 'allowed' Set and the corresponding return mapping in parseEvalSessionCliArgs (packages/paperclip-runner/src/cli/eval-session.ts:38)","Verify shell quoting/word splitting didn't shift arguments into even positions"],"exampleFix":"// before\nnode eval-session.ts --request-path req.json --output out.json\n// after\nnode eval-session.ts --request req.json --output out.json","handlingStrategy":"validation","validationCode":"const allowed = new Set([\"--request\", \"--output\"]);\nfunction validateEvalSessionArgs(args: string[]): string | null {\n  for (let i = 0; i < args.length; i += 2) {\n    if (!allowed.has(args[i] ?? \"\")) return `unknown argument: ${args[i] ?? \"\"}`;\n    if (args[i + 1] === undefined) return `missing ${args[i]}`;\n  }\n  return null;\n}","typeGuard":"function isKnownFlag(arg: string | undefined): arg is \"--request\" | \"--output\" {\n  return arg === \"--request\" || arg === \"--output\";\n}","tryCatchPattern":"try {\n  await runEvalSessionCli(args);\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith(\"unknown argument:\")) {\n    console.error(`Usage: eval-session --request <path> --output <path>\\n${error.message}`);\n    process.exitCode = 1;\n    return;\n  }\n  throw error;\n}","preventionTips":["Only invoke with the documented flags: --request and --output","Wrap the binary in a shell script/npm script that hardcodes the correct flag names","If a value can legitimately start with '--' in your paths, avoid such paths since argument() rejects them","Add a smoke test calling parseEvalSessionCliArgs with your project's canonical invocation"],"tags":["cli","argument-parsing","validation"],"backgroundTag":"unknown-cli-flag","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}