nodejs/node · error

invalid argument -%c\n

Error message

invalid argument -%c\n

What it means

After all known single-letter options are exhausted, brotli checks whether the char is one of the parameterized options (`o/q/w/C/D/S`). If not, it is an unknown short option and the parser prints `invalid argument -<c>` and aborts. The char is interpolated into the message.

Source

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

          concatenated_set = BROTLI_TRUE;
          params->allow_concatenated = BROTLI_TRUE;
          continue;
        } else if (c == 'V') {
          /* Don't parse further. */
          return COMMAND_VERSION;
        } else if (c == 'Z') {
          if (quality_set) {
            fprintf(stderr, "quality already set\n");
            return COMMAND_INVALID;
          }
          quality_set = BROTLI_TRUE;
          params->quality = 11;
          continue;
        }
        /* o/q/w/C/D/S with parameter is expected */
        if (c != 'o' && c != 'q' && c != 'w' && c != 'C' && c != 'D' &&
            c != 'S') {
          fprintf(stderr, "invalid argument -%c\n", c);
          return COMMAND_INVALID;
        }
        if (j + 1 != arg_len) {
          fprintf(stderr, "expected parameter for argument -%c\n", c);
          return COMMAND_INVALID;
        }
        i++;
        if (i == argc || !argv[i] || argv[i][0] == 0) {
          fprintf(stderr, "expected parameter for argument -%c\n", c);
          return COMMAND_INVALID;
        }
        params->not_input_indices[next_option_index++] = i;
        if (c == 'o') {
          if (output_set) {
            fprintf(stderr, "write to standard output already set (-o)\n");
            return COMMAND_INVALID;
          }
          params->output_path = argv[i];

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Run `brotli --help` and replace the unknown short option with a supported equivalent.
  2. For numeric quality use `-q N` (0..11) or `-Z`/`--best` instead of `-N`.
  3. Check for shell alias expansion that may have injected the stray character.

Example fix

# before
brotli -9 in.txt
# after
brotli -q 9 in.txt
Defensive patterns

Strategy: validation

Validate before calling

# bash: reject unknown short options
known='cdfhjkKntvVZoq wCDS'
for a in "$@"; do
  case "$a" in
    --*) ;;
    -*)
      rest=${a#-}
      while [ -n "$rest" ]; do
        c=${rest:0:1}; rest=${rest:1}
        case " "$known" " in *" "$c "*) ;; *) echo "unknown -<$c>" >&2; exit 2;; esac
      done
      ;;
  esac
done
brotli "$@"

Try / catch

# bash
if ! brotli "$@"; then rc=$?; echo "brotli exit $rc; check for unsupported flags" >&2; exit "$rc"; fi

Prevention

When it happens

Trigger: Supplying an unsupported short flag, e.g. `brotli -x f`, `brotli -1 f` (brotli has no gzip-style `-1`), or a typo like `brotli -d -v` followed by stray chars.

Common situations: Carrying over gzip/zstd muscle memory (`-1`..`-9`, `-r`); typos; man-page / help from a different brotli version.

Related errors


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