{"record":{"id":"2a3ab8ee70305fab","repo":"nodejs/node","slug":"command-already-set-when-parsing-decompress-n","errorCode":null,"errorMessage":"command already set when parsing --decompress\\n","messagePattern":"command already set when parsing --decompress\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":526,"sourceCode":"      arg = &arg[2];\n      if (strcmp(\"best\", arg) == 0) {\n        if (quality_set) {\n          fprintf(stderr, \"quality already set\\n\");\n          return COMMAND_INVALID;\n        }\n        quality_set = BROTLI_TRUE;\n        params->quality = 11;\n      } else if (strcmp(\"concatenated\", arg) == 0) {\n        if (concatenated_set) {\n          fprintf(stderr, \"argument -K / --concatenated already set\\n\");\n          return COMMAND_INVALID;\n        }\n        concatenated_set = BROTLI_TRUE;\n        params->allow_concatenated = BROTLI_TRUE;\n        continue;\n      } else if (strcmp(\"decompress\", arg) == 0) {\n        if (command_set) {\n          fprintf(stderr, \"command already set when parsing --decompress\\n\");\n          return COMMAND_INVALID;\n        }\n        command_set = BROTLI_TRUE;\n        command = COMMAND_DECOMPRESS;\n      } else if (strcmp(\"force\", arg) == 0) {\n        if (params->force_overwrite) {\n          fprintf(stderr, \"force output overwrite already set\\n\");\n          return COMMAND_INVALID;\n        }\n        params->force_overwrite = BROTLI_TRUE;\n      } else if (strcmp(\"help\", arg) == 0) {\n        /* Don't parse further. */\n        return COMMAND_HELP;\n      } else if (strcmp(\"keep\", arg) == 0) {\n        if (keep_set) {\n          fprintf(stderr, \"argument --rm / -j or --keep / -k already set\\n\");\n          return COMMAND_INVALID;\n        }","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L508-L544","documentation":"`--decompress` sets the operation mode (`command = COMMAND_DECOMPRESS`) and is guarded by the shared `command_set` latch, which is also flipped by `-d`, `-z` (compress), `-t` (test), and other mode selectors. Specifying two different (or duplicate) commands is rejected so the intended action is unambiguous.","triggerScenarios":"`brotli -d --decompress in`, `brotli -z --decompress in`, `brotli -t --decompress in`, or `brotli --decompress --decompress in`.","commonSituations":"Invoking brotli through a symlink alias (e.g. `unbrotli`) that already implies decompress, plus an explicit `--decompress`; scripts layering mode flags; calling the binary as both `brotli -d` and adding `--decompress` defensively.","solutions":["Pass exactly one mode flag (`-d`, `-z`, `-t`, `--decompress`, etc.).","If relying on a program-name alias for the mode, do not also pass an explicit mode flag.","Inspect the resolved argv (print it) to find the duplicate source."],"exampleFix":"# before\nbrotli -d --decompress in.br\n# after\nbrotli -d in.br","handlingStrategy":"validation","validationCode":"# bash: at most one command/mode flag (covers aliases)\nm=$(printf '%s\\n' \"$@\" | grep -cE '^(-d|-z|-t|--compress|--decompress|--test.*)$')\nif [ \"$m\" -gt 1 ]; then echo \"multiple command/mode flags\" >&2; exit 2; fi\nbrotli \"$@\"","typeGuard":null,"tryCatchPattern":"# bash\nif ! brotli \"$@\"; then rc=$?; echo \"brotli exit $rc; check for duplicate command flag\" >&2; exit \"$rc\"; fi","preventionTips":["Do not combine explicit mode flags when invoking via a program-name alias (e.g. unbrotli).","Pick a single source for the mode: alias, env, or CLI flag."],"tags":["cli","brotli","argument-parsing","duplicate-flag","command-mode"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}