{"record":{"id":"6588910eb93b5887","repo":"nodejs/node","slug":"u-failure","errorCode":"U_FAILURE","errorMessage":"icupkg: udata_openSwapper(\\\"%s\\\") failed - %s\\n","messagePattern":"icupkg: udata_openSwapper\\(\\\\\"(.+?)\\\\\"\\) failed - (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/package.cpp","lineNumber":471,"sourceCode":"    char type;\n\n    const UDataOffsetTOCEntry *inEntries;\n\n    extractPackageName(filename, inPkgName, static_cast<int32_t>(sizeof(inPkgName)));\n\n    /* read the file */\n    inData=readFile(nullptr, filename, inLength, type);\n    length=inLength;\n\n    /*\n     * swap the header - even if the swapping itself is a no-op\n     * because it tells us the header length\n     */\n    errorCode=U_ZERO_ERROR;\n    makeTypeProps(type, inCharset, inIsBigEndian);\n    ds=udata_openSwapper(inIsBigEndian, inCharset, U_IS_BIG_ENDIAN, U_CHARSET_FAMILY, &errorCode);\n    if(U_FAILURE(errorCode)) {\n        fprintf(stderr, \"icupkg: udata_openSwapper(\\\"%s\\\") failed - %s\\n\",\n                filename, u_errorName(errorCode));\n        exit(errorCode);\n    }\n\n    ds->printError=printPackageError;\n    ds->printErrorContext=stderr;\n\n    headerLength=sizeof(header);\n    if(length<headerLength) {\n        headerLength=length;\n    }\n    headerLength=udata_swapDataHeader(ds, inData, headerLength, header, &errorCode);\n    if(U_FAILURE(errorCode)) {\n        exit(errorCode);\n    }\n\n    /* check data format and format version */\n    pInfo = reinterpret_cast<const UDataInfo*>(reinterpret_cast<const char*>(inData) + 4);","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/package.cpp#L453-L489","documentation":"Thrown by Package::readPackage() when udata_openSwapper() returns a failure UErrorCode. The swapper is created to handle byte-order and charset conversion between the input data's native format (determined by makeTypeProps from the type letter) and the host's format. If the swapper cannot be initialized, the input format combination is unsupported.","triggerScenarios":"Calling readPackage() on a .dat file where makeTypeProps(type, ...) produces a charset/endian combination that udata_openSwapper() cannot handle. The type is determined by getTypeEnumForInputData() during the initial readFile() pass, so this implies the file passed the initial format check but the swapper rejects the specific source platform parameters.","commonSituations":"A .dat file from an exotic platform (e.g. EBCDIC) that the host ICU build does not have conversion tables for; ICU version mismatch where the swapper API behavior changed; corrupt header values that produce invalid charset/endian flags.","solutions":["Check the error message suffix (u_errorName output) for the specific UErrorCode.","Ensure the ICU build includes the necessary conversion tables for the source charset.","Use an icupkg version matching the ICU version that produced the data file.","If EBCDIC data is involved, build ICU with EBCDIC conversion support enabled."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the .dat file's type letter is supported before processing\n#include <cstring>\nbool isSupportedType(char typeLetter) {\n    // Supported types: 'l' (little-endian ASCII), 'b' (big-endian ASCII),\n    // 'e' (EBCDIC, requires legacy conversion support)\n    return typeLetter == 'l' || typeLetter == 'b' || typeLetter == 'e';\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the ICU build has conversion support for the source data's charset.","Use icupkg from the same ICU version that produced the data.","Avoid EBCDIC-sourced data unless the build explicitly supports it."],"tags":["icu","icupkg","swapper","charset","endian","conversion","unsupported"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}