nodejs/node · error

command already set when parsing -d

Error message

command already set when parsing -d

What it means

brotli's command-mode flags are mutually exclusive: `-d` (decompress), `-t` (test integrity). Once a command mode is set, passing `-d` again is rejected.

Source

Thrown at deps/brotli/c/tools/brotli.c:357

        if (c >= '0' && c <= '9') {
          if (quality_set) {
            fprintf(stderr, "quality already set\n");
            return COMMAND_INVALID;
          }
          quality_set = BROTLI_TRUE;
          params->quality = c - '0';
          continue;
        } else if (c == 'c') {
          if (output_set) {
            fprintf(stderr, "write to standard output already set\n");
            return COMMAND_INVALID;
          }
          output_set = BROTLI_TRUE;
          params->write_to_stdout = BROTLI_TRUE;
          continue;
        } else if (c == 'd') {
          if (command_set) {
            fprintf(stderr, "command already set when parsing -d\n");
            return COMMAND_INVALID;
          }
          command_set = BROTLI_TRUE;
          command = COMMAND_DECOMPRESS;
          continue;
        } else if (c == 'f') {
          if (params->force_overwrite) {
            fprintf(stderr, "force output overwrite already set\n");
            return COMMAND_INVALID;
          }
          params->force_overwrite = BROTLI_TRUE;
          continue;
        } else if (c == 'h') {
          /* Don't parse further. */
          return COMMAND_HELP;
        } else if (c == 'j' || c == 'k') {
          if (keep_set) {
            fprintf(stderr, "argument --rm / -j or --keep / -k already set\n");

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Use exactly one command-mode flag.
  2. Remove the conflicting mode from your alias or command.

Example fix

// before
brotli -d -t file.br   # two command modes
// after
brotli -t file.br      # test integrity only
Defensive patterns

Strategy: validation

Validate before calling

modes=[a for a in argv if a in ('-d','-t','--decompress','--test') or (a.startswith('-') and not a.startswith('--') and ('d' in a or 't' in a))]
assert len(modes) <= 1, 'only one command mode (-d/-t) allowed'

Prevention

When it happens

Trigger: `brotli -d -t file`, `brotli -d -d file`, or a coalesced `brotli -dt file`.

Common situations: An alias that decompresses (`-d`) combined with a user-added `-t`; a wrapper merging two modes; misunderstanding that test and decompress cannot combine.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/22c8369e20e2ed46. Report an issue: GitHub.