nodejs/node · error

input file [%s] suffix mismatch\n

Error message

input file [%s] suffix mismatch\n

What it means

During decompression with automatic output naming, the input file's basename does not end with the expected suffix (default `.br`, or whatever was set via `--suffix=`). The `strcmp(context->suffix, name_suffix)` check failed, meaning the trailing characters don't match the configured decompression suffix.

Source

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

  if (context->write_to_stdout) return BROTLI_TRUE;

  strcpy(context->modified_path, arg);
  context->current_output_path = context->modified_path;
  /* If output is not specified, input path suffix should match. */
  if (context->decompress) {
    size_t suffix_len = strlen(context->suffix);
    char* name = (char*)FileName(context->modified_path);
    char* name_suffix;
    size_t name_len = strlen(name);
    if (name_len < suffix_len + 1) {
      fprintf(stderr, "empty output file name for [%s] input file\n",
              PrintablePath(arg));
      context->iterator_error = BROTLI_TRUE;
      return BROTLI_FALSE;
    }
    name_suffix = name + name_len - suffix_len;
    if (strcmp(context->suffix, name_suffix) != 0) {
      fprintf(stderr, "input file [%s] suffix mismatch\n",
              PrintablePath(arg));
      context->iterator_error = BROTLI_TRUE;
      return BROTLI_FALSE;
    }
    name_suffix[0] = 0;
    return BROTLI_TRUE;
  } else {
    strcpy(context->modified_path + arg_len, context->suffix);
    return BROTLI_TRUE;
  }
}

static BROTLI_BOOL OpenFiles(Context* context) {
  BROTLI_BOOL is_ok = OpenInputFile(context->current_input_path, &context->fin);
  if (!context->test_integrity && is_ok) {
    is_ok = OpenOutputFile(
        context->current_output_path, &context->fout, context->force_overwrite);
  }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Provide an explicit output path to bypass suffix checking: `brotli -d -o output.txt data.xyz`.
  2. Set `--suffix=` to match the actual extension: `brotli -d --suffix=.brotli data.brotli`.
  3. Use `--stdout` / `-c` to avoid name derivation entirely.
  4. Rename the input file to have the `.br` extension if it is indeed a brotli file.

Example fix

// before
brotli -d data.brotli   # suffix is .br by default
// after
brotli -d --suffix=.brotli data.brotli
Defensive patterns

Strategy: validation

Validate before calling

#include <string.h>
#include <stdbool.h>
#include <libgen.h>

bool suffix_matches(const char *input_path, const char *suffix) {
    char buf[4096];
    strncpy(buf, input_path, sizeof(buf) - 1);
    buf[sizeof(buf) - 1] = 0;
    char *base = basename(buf);
    size_t base_len = strlen(base);
    size_t suffix_len = strlen(suffix);
    if (base_len < suffix_len) return false;
    return strcmp(base + base_len - suffix_len, suffix) == 0;
}

Prevention

When it happens

Trigger: Running `brotli -d` on a file that doesn't have the `.br` extension (e.g. `data.gz`, `data.txt`, `data.brotli`); a custom suffix was set via `--suffix=.brotli` but the file uses `.br`.

Common situations: Files renamed without updating the extension; mixing up gzip/brotli/zstd files; a non-standard suffix configured on one system but not another.

Related errors


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