nodejs/node · error

dictionary path already set\n

Error message

dictionary path already set\n

What it means

`-D PATH` provides a custom dictionary file for compression/decompression (`params->dictionary_path`). It is latched by a non-null check; a second `-D` is rejected so the active dictionary is unambiguous.

Source

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

            fprintf(stderr,
                    "lgwin parameter (%d) smaller than the minimum (%d)\n",
                    params->lgwin, BROTLI_MIN_WINDOW_BITS);
            return COMMAND_INVALID;
          }
        } else if (c == 'C') {
          if (comment_set) {
            fprintf(stderr, "comment already set\n");
            return COMMAND_INVALID;
          }
          params->comment_len = MAX_COMMENT_LEN;
          if (!ParseBase64(argv[i], params->comment, &params->comment_len)) {
            fprintf(stderr, "invalid base64-encoded comment\n");
            return COMMAND_INVALID;
          }
          comment_set = BROTLI_TRUE;
        } else if (c == 'D') {
          if (params->dictionary_path) {
            fprintf(stderr, "dictionary path already set\n");
            return COMMAND_INVALID;
          }
          params->dictionary_path = argv[i];
        } else if (c == 'S') {
          if (suffix_set) {
            fprintf(stderr, "suffix already set\n");
            return COMMAND_INVALID;
          }
          suffix_set = BROTLI_TRUE;
          params->suffix = argv[i];
        }
      }
    } else {  /* Double-dash. */
      arg = &arg[2];
      if (strcmp("best", arg) == 0) {
        if (quality_set) {
          fprintf(stderr, "quality already set\n");
          return COMMAND_INVALID;

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Pass exactly one dictionary path.
  2. Merge dictionaries offline into a single file if both are needed.

Example fix

# before
brotli -D a.dict -D b.dict in
# after
brotli -D a.dict in
Defensive patterns

Strategy: validation

Validate before calling

# bash: at most one dictionary setter
d=$(printf '%s\n' "$@" | grep -cE '^(-D|--dictionary=.*)$')
if [ "$d" -gt 1 ]; then echo "multiple dictionary flags" >&2; exit 2; fi
brotli "$@"

Try / catch

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

Prevention

When it happens

Trigger: `brotli -D dict1 -D dict2 in`, or `-D` combined with `--dictionary=...`.

Common situations: Layered configs that both inject a dictionary path; switching dictionaries without removing the previous flag.

Related errors


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