{"record":{"id":"4e297bee41fe7e51","repo":"nodejs/node","slug":"u-file-access-error-4e297b","errorCode":"U_FILE_ACCESS_ERROR","errorMessage":"error opening preparsed UCD file %s\n","messagePattern":"error opening preparsed UCD file (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/ppucd.cpp","lineNumber":64,"sourceCode":"\nPreparsedUCD::PreparsedUCD(const char *filename, UErrorCode &errorCode)\n        : pnames(nullptr),\n          file(nullptr),\n          defaultLineIndex(-1), blockLineIndex(-1), lineIndex(0),\n          lineNumber(0),\n          lineType(NO_LINE),\n          fieldLimit(nullptr), lineLimit(nullptr) {\n    if(U_FAILURE(errorCode)) { return; }\n\n    if(filename==nullptr || *filename==0 || (*filename=='-' && filename[1]==0)) {\n        filename=nullptr;\n        file=stdin;\n    } else {\n        file=fopen(filename, \"r\");\n    }\n    if(file==nullptr) {\n        perror(\"error opening preparsed UCD\");\n        fprintf(stderr, \"error opening preparsed UCD file %s\\n\", filename ? filename : \"\\\"no file name given\\\"\");\n        errorCode=U_FILE_ACCESS_ERROR;\n        return;\n    }\n\n    memset(ucdVersion, 0, 4);\n    lines[0][0]=0;\n}\n\nPreparsedUCD::~PreparsedUCD() {\n    if(file!=stdin) {\n        fclose(file);\n    }\n}\n\n// Same order as the LineType values.\nstatic const char *lineTypeStrings[]={\n    nullptr,\n    nullptr,","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/ppucd.cpp#L46-L82","documentation":"Thrown by the PreparsedUCD constructor when fopen() fails to open the specified preparsed Unicode Character Database (UCD) file. The file path is printed (or 'no file name given' if null/empty), and errorCode is set to U_FILE_ACCESS_ERROR. This is the entry point for reading preparsed UCD data used by ICU's character property generation tools.","triggerScenarios":"Constructing a PreparsedUCD object with a filename that does not exist, is not readable, or has incorrect permissions. The fopen(filename, \"r\") call returns nullptr, triggering the perror and fprintf at ppucd.cpp:64.","commonSituations":"Wrong or missing file path to the preparsed UCD file; file doesn't exist in the expected build directory; permission denied; build system pointing to a stale or non-existent path; typo in the filename argument.","solutions":["Verify the file path exists and is readable (ls -l, check permissions).","Ensure the preparsed UCD file was generated by the ICU build system before running the tool that consumes it.","Pass the correct absolute path or fix the build system's output directory configuration."],"exampleFix":"// before: file path doesn't exist\nPreparsedUCD *pucd = new PreparsedUCD(\"build/ucd/preparsed.txt\", errorCode);\n\n// after: verify path and pass correct location\n// run: ls -l /path/to/icu/source/output/preparsed.txt\nPreparsedUCD *pucd = new PreparsedUCD(\"/abs/path/to/output/preparsed.txt\", errorCode);\nif (U_FAILURE(errorCode)) { /* handle */ }","handlingStrategy":"validation","validationCode":"// Validate file exists and is readable before constructing PreparsedUCD\nimport os\npreparsed_path = 'build/ucd/preparsed.txt'\nif not os.path.isfile(preparsed_path):\n    raise FileNotFoundError(f'Preparsed UCD file not found: {preparsed_path}')\nif not os.access(preparsed_path, os.R_OK):\n    raise PermissionError(f'Cannot read preparsed UCD file: {preparsed_path}')","typeGuard":null,"tryCatchPattern":"// C++: check errorCode after constructing PreparsedUCD\nPreparsedUCD *pucd = new PreparsedUCD(filename, errorCode);\nif (U_FAILURE(errorCode)) {\n    if (errorCode == U_FILE_ACCESS_ERROR) {\n        fprintf(stderr, \"Cannot open preparsed UCD: %s\\n\", filename);\n    }\n    // handle error\n    return;\n}","preventionTips":["Verify the file path exists with os.path.isfile / stat before passing it.","Ensure the preparsed UCD file is generated by the build system before running the consumer tool.","Use absolute paths to avoid working-directory ambiguity."],"tags":["icu","ucd","file-access","preparsed-ucd","constructor"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}