{"record":{"id":"1fa29443c5cd590a","repo":"affaan-m/ECC","slug":"json-may-only-be-provided-once","errorCode":null,"errorMessage":"--json may only be provided once","messagePattern":"--json may only be provided once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/ito.js","lineNumber":161,"sourceCode":"  if (\n    args.length === 0\n    || args.includes(\"--help\")\n    || args.includes(\"-h\")\n  ) {\n    return Object.freeze({ help: true, invocationArgs: [] });\n  }\n\n  if (environment.ECC_DRY_RUN === \"1\" || args.includes(\"--dry-run\")) {\n    throw new Error(\n      \"Itô compute has no paper or dry-run success mode. No CLI operation was invoked.\"\n    );\n  }\n\n  const jsonIndexes = args\n    .map((value, index) => (value === \"--json\" ? index : -1))\n    .filter((index) => index >= 0);\n  if (jsonIndexes.length > 1) {\n    throw new Error(\"--json may only be provided once\");\n  }\n  const withoutJson = args.filter((value) => value !== \"--json\");\n  const command = withoutJson.shift();\n  if (!SUPPORTED_COMMANDS.includes(command)) {\n    throw new Error(\n      `Unsupported Itô command \"${command || \"(missing)\"}\"; ECC permits only login, logout, auth, find, status, and evals.`\n    );\n  }\n  if (command === \"auth\" && withoutJson.includes(\"--no-browser\")) {\n    throw new Error(\"--no-browser is valid only for ecc ito login; auth is validation-only.\");\n  }\n  if (command === \"evals\") {\n    validateNodeQualificationArgs(withoutJson, environment);\n  }\n\n  return Object.freeze({\n    help: false,\n    invocationArgs: Object.freeze([","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ito.js#L143-L179","documentation":"Thrown by parseArgs at scripts/ito.js:161 when the --json flag appears more than once in argv. The bridge forwards --json to the canonical Itô CLI exactly once (ito.js:180) and the JSON output mode is a single boolean toggle; passing it twice is treated as a malformed invocation rather than a no-op. This check runs before command validation, so it fires even for unknown commands.","triggerScenarios":"`ecc ito status --json --json`; `ecc ito --json find <opts> --json`; any invocation where the args array contains the literal token '--json' at two or more positions.","commonSituations":"A wrapper script appends --json unconditionally and the operator also types it; or a shell alias includes --json and the user adds it again. Aliases like `alias eitoj='ecc ito --json'` combined with `eitoj status --json` are the most common cause.","solutions":["Pass --json exactly once: `ecc ito status --json`.","Check your shell alias / function for a hardcoded --json: `alias eitoj; type eitoj`.","If a wrapper script toggles JSON via a variable, guard with `[ -n \"$JSON\" ] && set -- --json \"$@\"` rather than always appending."],"exampleFix":"// before\n$ ecc ito --json status --json\n// after\n$ ecc ito status --json","handlingStrategy":"validation","validationCode":"function dedupeJsonFlag(argv) {\n  const count = argv.filter(a => a === '--json').length;\n  if (count > 1) throw new Error(`--json passed ${count} times; expected at most 1`);\n  return argv;\n}\n// before invoking ecc ito\ndedupeJsonFlag(args);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define shell aliases without --json and add it explicitly when needed.","In wrapper scripts, append --json conditionally (`if [ \"$JSON\" = 1 ]; then set -- --json \"$@\"; fi`) rather than always.","Lint wrapper scripts that build ecc argv to detect duplicate tokens."],"tags":["cli","validation","json","ito"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}