{"record":{"id":"fda68168bbf026ef","repo":"nodejs/node","slug":"failed-to-open-input-file-s-s-n","errorCode":null,"errorMessage":"failed to open input file [%s]: %s\\n","messagePattern":"failed to open input file \\[(.+?)\\]: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":788,"sourceCode":"\"  -Z, --best                  use best compression level (11) (default)\\n\"\n\"Simple options could be coalesced, i.e. '-9kf' is equivalent to '-9 -k -f'.\\n\"\n\"With no FILE, or when FILE is -, read standard input.\\n\"\n\"All arguments after '--' are treated as files.\\n\");\n}\n\nstatic const char* PrintablePath(const char* path) {\n  return path ? path : \"con\";\n}\n\nstatic BROTLI_BOOL OpenInputFile(const char* input_path, FILE** f) {\n  *f = NULL;\n  if (!input_path) {\n    *f = fdopen(MAKE_BINARY(STDIN_FILENO), \"rb\");\n    return BROTLI_TRUE;\n  }\n  *f = fopen(input_path, \"rb\");\n  if (!*f) {\n    fprintf(stderr, \"failed to open input file [%s]: %s\\n\",\n            PrintablePath(input_path), strerror(errno));\n    return BROTLI_FALSE;\n  }\n  return BROTLI_TRUE;\n}\n\nstatic BROTLI_BOOL OpenOutputFile(const char* output_path, FILE** f,\n                                  BROTLI_BOOL force) {\n  int fd;\n  *f = NULL;\n  if (!output_path) {\n    *f = fdopen(MAKE_BINARY(STDOUT_FILENO), \"wb\");\n    return BROTLI_TRUE;\n  }\n  fd = open(output_path, O_CREAT | (force ? 0 : O_EXCL) | O_WRONLY | O_TRUNC,\n            S_IRUSR | S_IWUSR);\n  if (fd < 0) {\n    fprintf(stderr, \"failed to open output file [%s]: %s\\n\",","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L770-L806","documentation":"`OpenInputFile` failed to `fopen` the given path in read-binary mode. The message prints the path (via `PrintablePath`, which substitutes \"con\" for NULL) and the errno string from `strerror(errno)`. This is a standard POSIX file-open failure.","triggerScenarios":"The input file does not exist (ENOENT), the caller lacks read permission (EACCES), a path component is not a directory (ENOTDIR), the file name is too long (ENAMETOOLONG), or too many files are open (EMFILE).","commonSituations":"Relative path resolved from an unexpected working directory; glob or find command returned a stale name; file on an NFS mount that is stale or unmounted; permissions changed between listing and reading.","solutions":["Verify the file exists and is readable: `ls -l <path>`.","Check the working directory if using a relative path.","Fix permissions with `chmod` or run as the appropriate user.","For stdin, omit the input path or use `-` instead of a filename."],"exampleFix":"// before\nbrotli ./data/input.bin\n// after\nbrotli /abs/path/data/input.bin","handlingStrategy":"validation","validationCode":"#include <unistd.h>\n#include <stdbool.h>\n\nbool input_file_readable(const char *path) {\n    if (!path) return true; // stdin is always attempted\n    return access(path, R_OK) == 0;\n}\n\n// Before calling brotli:\n//   if (!input_file_readable(path)) { handle_error(path); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve all input paths to absolute paths before passing to brotli.","Check `access(path, R_OK)` before invoking to fail early with a clear message.","Verify file existence in the same working directory brotli will run in."],"tags":["filesystem","io","brotli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}