nodejs/node · error

quality already set

Error message

quality already set

What it means

The brotli CLI sets compression quality from a digit (e.g. `-9`, or a digit inside a coalesced short-option cluster). Quality may be set only once; a second digit/quality specifier is rejected as ambiguous.

Source

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

    }

    /* 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;
    }

    /* Simple / coalesced options. */
    if (arg[1] != '-') {
      size_t j;
      for (j = 1; j < arg_len; ++j) {
        char c = arg[j];
        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;
          }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Pass quality exactly once (either -q N or a single -N digit).
  2. Remove the duplicate quality flag from your alias or script.

Example fix

// before
brotli -9 -5 file.br   # quality set twice
// after
brotli -9 file.br      # quality set once
Defensive patterns

Strategy: validation

Validate before calling

# detect duplicate quality specifiers in argv before invoking brotli
qs=[a for a in argv if a.startswith('-q')] + [a for a in argv if a.startswith('-') and any(c.isdigit() for c in a[1:])]
assert len(qs) <= 1, 'quality specified more than once'

Prevention

When it happens

Trigger: Passing two quality values, e.g. `brotli -9 -5 file`, a coalesced `brotli -95 file`, or `brotli -q 5 -9 file`.

Common situations: An alias or wrapper that already sets quality plus an explicit flag from the user; copy-pasted command lines combining two examples.

Related errors


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