nodejs/node · error

empty output file name for [%s] input file\n

Error message

empty output file name for [%s] input file\n

What it means

During decompression with automatic output naming (no `--output`, no stdout mode), stripping the configured suffix from the input filename would leave an empty string. The check `name_len < suffix_len + 1` fires when the filename portion (after the last path separator) is shorter than the suffix plus at least one base character.

Source

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

  }

  context->current_input_path = arg;
  context->input_file_length = FileSize(arg);
  context->current_output_path = context->output_path;

  if (context->output_path) return BROTLI_TRUE;
  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;
  }
}

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Provide an explicit output path: `brotli -d -o output.txt .br`.
  2. Rename the input file so it has a non-empty base name before the suffix.
  3. Use `-c` / `--stdout` to write decompressed data to stdout instead of deriving a name.

Example fix

// before
brotli -d .br
// after
brotli -d -o data.txt .br
Defensive patterns

Strategy: validation

Validate before calling

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

bool output_name_nonempty(const char *input_path, const char *suffix) {
    // Extract basename, check that stripping suffix leaves at least 1 char
    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);
    return base_len >= suffix_len + 1;
}

Prevention

When it happens

Trigger: The input filename's basename is exactly the suffix (e.g. input file is `.br` with default suffix `.br`, leaving an empty name), or the basename is the same length as the suffix with nothing before it.

Common situations: A file literally named `.br` or `.br.br` processed in decompress mode without `--output`; unusual filenames from automated pipelines that strip everything except the extension.

Related errors


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