{"record":{"id":"653272d7a911e6da","repo":"nodejs/node","slug":"empty-output-file-name-for-s-input-file-n","errorCode":null,"errorMessage":"empty output file name for [%s] input file\\n","messagePattern":"empty output file name for \\[(.+?)\\] input file\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":998,"sourceCode":"  }\n\n  context->current_input_path = arg;\n  context->input_file_length = FileSize(arg);\n  context->current_output_path = context->output_path;\n\n  if (context->output_path) return BROTLI_TRUE;\n  if (context->write_to_stdout) return BROTLI_TRUE;\n\n  strcpy(context->modified_path, arg);\n  context->current_output_path = context->modified_path;\n  /* If output is not specified, input path suffix should match. */\n  if (context->decompress) {\n    size_t suffix_len = strlen(context->suffix);\n    char* name = (char*)FileName(context->modified_path);\n    char* name_suffix;\n    size_t name_len = strlen(name);\n    if (name_len < suffix_len + 1) {\n      fprintf(stderr, \"empty output file name for [%s] input file\\n\",\n              PrintablePath(arg));\n      context->iterator_error = BROTLI_TRUE;\n      return BROTLI_FALSE;\n    }\n    name_suffix = name + name_len - suffix_len;\n    if (strcmp(context->suffix, name_suffix) != 0) {\n      fprintf(stderr, \"input file [%s] suffix mismatch\\n\",\n              PrintablePath(arg));\n      context->iterator_error = BROTLI_TRUE;\n      return BROTLI_FALSE;\n    }\n    name_suffix[0] = 0;\n    return BROTLI_TRUE;\n  } else {\n    strcpy(context->modified_path + arg_len, context->suffix);\n    return BROTLI_TRUE;\n  }\n}","sourceCodeStart":980,"sourceCodeEnd":1016,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L980-L1016","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide an explicit output path: `brotli -d -o output.txt .br`.","Rename the input file so it has a non-empty base name before the suffix.","Use `-c` / `--stdout` to write decompressed data to stdout instead of deriving a name."],"exampleFix":"// before\nbrotli -d .br\n// after\nbrotli -d -o data.txt .br","handlingStrategy":"validation","validationCode":"#include <string.h>\n#include <stdbool.h>\n#include <libgen.h>\n\nbool output_name_nonempty(const char *input_path, const char *suffix) {\n    // Extract basename, check that stripping suffix leaves at least 1 char\n    char buf[4096];\n    strncpy(buf, input_path, sizeof(buf) - 1);\n    buf[sizeof(buf) - 1] = 0;\n    char *base = basename(buf);\n    size_t base_len = strlen(base);\n    size_t suffix_len = strlen(suffix);\n    return base_len >= suffix_len + 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide `--output` / `-o` when decompressing files with minimal basenames.","Avoid creating files whose basename is just the extension.","Use `-c` to write to stdout and avoid name derivation entirely."],"tags":["filename","decompression","suffix","brotli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}