{"record":{"id":"882b648e69de63bb","repo":"nodejs/node","slug":"too-many-options-passed","errorCode":null,"errorMessage":"too many options passed\n","messagePattern":"too many options passed\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":314,"sourceCode":"  }\n\n  for (i = 1; i < argc; ++i) {\n    const char* arg = argv[i];\n    /* C99 5.1.2.2.1: \"members argv[0] through argv[argc-1] inclusive shall\n       contain pointers to strings\"; NULL and 0-length are not forbidden. */\n    size_t arg_len = arg ? strlen(arg) : 0;\n\n    if (arg_len == 0) {\n      params->not_input_indices[next_option_index++] = i;\n      continue;\n    }\n\n    /* Too many options. The expected longest option list is:\n       \"-q 0 -w 10 -o f -D d -S b -d -f -k -n -v -K --\", i.e. 17 items in total.\n       This check is an additional guard that is never triggered, but provides\n       a guard for future changes. */\n    if (next_option_index > (MAX_OPTIONS - 2)) {\n      fprintf(stderr, \"too many options passed\\n\");\n      return COMMAND_INVALID;\n    }\n\n    /* Input file entry. */\n    if (after_dash_dash || arg[0] != '-' || arg_len == 1) {\n      input_count++;\n      if (longest_path_len < arg_len) longest_path_len = arg_len;\n      continue;\n    }\n\n    /* Not a file entry. */\n    params->not_input_indices[next_option_index++] = i;\n\n    /* '--' entry stop parsing arguments. */\n    if (arg_len == 2 && arg[1] == '-') {\n      after_dash_dash = BROTLI_TRUE;\n      continue;\n    }","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L296-L332","documentation":"The brotli CLI records non-input option positions in a fixed-size array (MAX_OPTIONS = 24). As a defensive guard for future changes it rejects an invocation once more than ~22 options accumulate. The code comment notes this should never trigger in normal use.","triggerScenarios":"Passing an unusually long argument list of flags to the brotli CLI, e.g. a script or glob that expands into many option tokens rather than input files.","commonSituations":"A generated/looped command line that concatenates many flags; accidental shell glob expansion producing flag-like tokens; a wrapper that re-specifies flags repeatedly.","solutions":["Reduce the option count: drop redundant flags (many are mutually exclusive and would trip earlier checks anyway).","Feed inputs via filenames/stdin instead of encoding everything as flags.","If scripting brotli heavily, build the argument list from a de-duplicated structure."],"exampleFix":"// before\nbrotli -q 9 -w 22 -o out -D dict -S .br -d -f -k -n -v -K -- $(seq 1 200)  # 200 flag-like tokens\n// after\nbrotli -q 9 -d -f *.br    # inputs are filenames, not flags","handlingStrategy":"validation","validationCode":"# in a shell wrapper: count option tokens before calling brotli\nopts=[a for a in argv if a.startswith('-')]\nassert len(opts) <= 22, f'too many options ({len(opts)}); simplify the invocation'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep brotli invocations minimal; pass data as input filenames, not flags.","De-duplicate flags when building argv programmatically."],"tags":["brotli","cli","argument-parsing","usage"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}