nodejs/node · error
too many options passed
Error message
too many options passed
What it means
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.
Source
Thrown at deps/brotli/c/tools/brotli.c:314
}
for (i = 1; i < argc; ++i) {
const char* arg = argv[i];
/* C99 5.1.2.2.1: "members argv[0] through argv[argc-1] inclusive shall
contain pointers to strings"; NULL and 0-length are not forbidden. */
size_t arg_len = arg ? strlen(arg) : 0;
if (arg_len == 0) {
params->not_input_indices[next_option_index++] = i;
continue;
}
/* Too many options. The expected longest option list is:
"-q 0 -w 10 -o f -D d -S b -d -f -k -n -v -K --", i.e. 17 items in total.
This check is an additional guard that is never triggered, but provides
a guard for future changes. */
if (next_option_index > (MAX_OPTIONS - 2)) {
fprintf(stderr, "too many options passed\n");
return COMMAND_INVALID;
}
/* Input file entry. */
if (after_dash_dash || arg[0] != '-' || arg_len == 1) {
input_count++;
if (longest_path_len < arg_len) longest_path_len = arg_len;
continue;
}
/* Not a file entry. */
params->not_input_indices[next_option_index++] = i;
/* '--' entry stop parsing arguments. */
if (arg_len == 2 && arg[1] == '-') {
after_dash_dash = BROTLI_TRUE;
continue;
}View on GitHub (pinned to 1b2de5e052)
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.
Example fix
// before brotli -q 9 -w 22 -o out -D dict -S .br -d -f -k -n -v -K -- $(seq 1 200) # 200 flag-like tokens // after brotli -q 9 -d -f *.br # inputs are filenames, not flags
Defensive patterns
Strategy: validation
Validate before calling
# in a shell wrapper: count option tokens before calling brotli
opts=[a for a in argv if a.startswith('-')]
assert len(opts) <= 22, f'too many options ({len(opts)}); simplify the invocation' Prevention
- Keep brotli invocations minimal; pass data as input filenames, not flags.
- De-duplicate flags when building argv programmatically.
When it happens
Trigger: 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.
Common situations: A generated/looped command line that concatenates many flags; accidental shell glob expansion producing flag-like tokens; a wrapper that re-specifies flags repeatedly.
Related errors
- quality already set
- write to standard output already set
- command already set when parsing -d
- force output overwrite already set\n
- argument --rm / -j or --keep / -k already set\n
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/882b648e69de63bb.
Report an issue: GitHub.