{"record":{"id":"bccc2527f005149d","repo":"nodejs/node","slug":"input-file-s-suffix-mismatch-n","errorCode":null,"errorMessage":"input file [%s] suffix mismatch\\n","messagePattern":"input file \\[(.+?)\\] suffix mismatch\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":1005,"sourceCode":"  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}\n\nstatic BROTLI_BOOL OpenFiles(Context* context) {\n  BROTLI_BOOL is_ok = OpenInputFile(context->current_input_path, &context->fin);\n  if (!context->test_integrity && is_ok) {\n    is_ok = OpenOutputFile(\n        context->current_output_path, &context->fout, context->force_overwrite);\n  }","sourceCodeStart":987,"sourceCodeEnd":1023,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L987-L1023","documentation":"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.","triggerScenarios":"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`.","commonSituations":"Files renamed without updating the extension; mixing up gzip/brotli/zstd files; a non-standard suffix configured on one system but not another.","solutions":["Provide an explicit output path to bypass suffix checking: `brotli -d -o output.txt data.xyz`.","Set `--suffix=` to match the actual extension: `brotli -d --suffix=.brotli data.brotli`.","Use `--stdout` / `-c` to avoid name derivation entirely.","Rename the input file to have the `.br` extension if it is indeed a brotli file."],"exampleFix":"// before\nbrotli -d data.brotli   # suffix is .br by default\n// after\nbrotli -d --suffix=.brotli data.brotli","handlingStrategy":"validation","validationCode":"#include <string.h>\n#include <stdbool.h>\n#include <libgen.h>\n\nbool suffix_matches(const char *input_path, const char *suffix) {\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    if (base_len < suffix_len) return false;\n    return strcmp(base + base_len - suffix_len, suffix) == 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set `--suffix=` to match the actual file extension before decompressing.","Provide `--output` explicitly to bypass suffix validation.","Use `-c` for stdout output to avoid name-derivation logic 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"}