{"record":{"id":"027cf0be5de5c3d1","repo":"affaan-m/ECC","slug":"missing-value-for-limit","errorCode":null,"errorMessage":"Missing value for --limit","messagePattern":"Missing value for --limit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/consult.js","lineNumber":220,"sourceCode":"  if (args.includes('--help') || args.includes('-h')) {\n    parsed.help = true;\n    return parsed;\n  }\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--json') {\n      parsed.json = true;\n    } else if (arg === '--target') {\n      if (!args[index + 1] || args[index + 1].startsWith('-')) {\n        throw new Error('Missing value for --target');\n      }\n      parsed.target = args[index + 1];\n      index += 1;\n    } else if (arg === '--limit') {\n      if (!args[index + 1]) {\n        throw new Error('Missing value for --limit');\n      }\n      parsed.limit = Math.min(parsePositiveInteger(args[index + 1], '--limit'), MAX_LIMIT);\n      index += 1;\n    } else if (arg.startsWith('-')) {\n      throw new Error(`Unknown argument: ${arg}`);\n    } else {\n      parsed.queryParts.push(arg);\n    }\n  }\n\n  if (!SUPPORTED_INSTALL_TARGETS.includes(parsed.target)) {\n    throw new Error(\n      `Unknown install target: ${parsed.target}. Expected one of ${SUPPORTED_INSTALL_TARGETS.join(', ')}`\n    );\n  }\n\n  parsed.query = parsed.queryParts.join(' ').trim();\n  return parsed;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/consult.js#L202-L238","documentation":"In consult.js parseArgs(), when --limit is encountered, the parser checks if argv[index + 1] exists. If it does not (i.e., --limit is the last argument), it throws before even attempting to parse the integer. Note that unlike --target, this check does not reject values starting with '-', so '--limit --target' would pass the existence check but then fail in parsePositiveInteger.","triggerScenarios":"Passing --limit as the last argument on the command line; a wrapper script that conditionally appends --limit but forgets the value.","commonSituations":"Dynamic command construction in Makefiles or CI YAML where the limit variable is empty; copy-paste from partial documentation.","solutions":["Provide a positive integer immediately after --limit, e.g. --limit 10","If building commands dynamically, ensure the limit variable is set before appending --limit","Omit --limit entirely to use the default of 5"],"exampleFix":"// before\nnode scripts/consult.js security --limit\n// after\nnode scripts/consult.js security --limit 10","handlingStrategy":"validation","validationCode":"// Verify --limit has a following value before invoking consult.js\nconst argv = process.argv.slice(2);\nconst limitIdx = argv.indexOf('--limit');\nif (limitIdx !== -1 && !argv[limitIdx + 1]) {\n  console.error('Missing value for --limit. Provide a positive integer.');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\n} catch (error) {\n  if (error.message === 'Missing value for --limit') {\n    console.error('Provide a positive integer after --limit, e.g. --limit 5');\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["Always place the integer value immediately after --limit","Omit --limit to use the default of 5 if you are unsure","In dynamic command builders, ensure the limit variable is truthy before appending the flag"],"tags":["cli","argument-parsing","consult"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}