{"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":"Error","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/ito.js#L143-L179","documentation":"parseArgs counts occurrences of the --json flag; providing it more than once throws this error. The flag is a toggle for JSON output and duplicates are treated as a caller mistake rather than silently deduplicated.","triggerScenarios":"Running `ecc ito status --json --json`, or composing argument arrays in scripts where both a wrapper and the inner command append --json, resulting in two occurrences.","commonSituations":"Shell wrappers that prepend their own --json on top of a user-supplied one; concatenating default flags arrays with user flags containing --json; fat-fingering the flag twice.","solutions":["Remove the duplicate --json so it appears at most once","In wrapper scripts, deduplicate before invoking: args = [...new Set(args.filter(a => a !== '--json')), ...(needsJson ? ['--json'] : [])]","Check where defaults and user args are merged and de-dupe the flag there"],"exampleFix":"// before\nconst args = [...baseArgs, '--json', ...userArgs]; // userArgs already has --json\n// after\nconst args = baseArgs.includes('--json') || userArgs.includes('--json')\n  ? [...baseArgs, ...userArgs.filter(a => a !== '--json'), '--json']\n  : [...baseArgs, ...userArgs];","handlingStrategy":"validation","validationCode":"function dedupeJson(args) {\n  const count = args.filter(a => a === '--json').length;\n  if (count > 1) throw new Error('--json provided more than once');\n  return args;\n}","typeGuard":null,"tryCatchPattern":"try {\n  runIto(args);\n} catch (e) {\n  if (e.message === '--json may only be provided once') {\n    runIto([...new Set(args.filter(a => a !== '--json')), '--json']);\n  } else throw e;\n}","preventionTips":["Merge default flag arrays and user flags with de-duplication","Let wrapper scripts own the --json flag instead of layering defaults on user input","Lint argv construction helpers to reject duplicate toggles"],"tags":["cli","duplicate-flag","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}