{"record":{"id":"2bef9d0289da98bd","repo":"nodejs/node","slug":"icupkg-udata-openswapper-s-failed-s","errorCode":null,"errorMessage":"icupkg: udata_openSwapper(\"%s\") failed - %s\n","messagePattern":"icupkg: udata_openSwapper\\(\"(.+?)\"\\) failed - (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"deps/icu-small/source/tools/toolutil/pkgitems.cpp","lineNumber":619,"sourceCode":"            {\n                /*\n                 * Swap the resource bundle (if necessary) so that we can use\n                 * the normal runtime uresdata.c code to read it.\n                 * We do not want to duplicate that code, especially not together with on-the-fly swapping.\n                 */\n                NativeItem nrb(pItem, ures_swap);\n                ures_enumDependencies(pItem->name, nrb.getDataInfo(), nrb.getBytes(), nrb.getLength(), check, context, this, &errorCode);\n                break;\n            }\n        case FMT_CNV:\n            {\n                // TODO: share/cache swappers\n                UDataSwapper *ds=udata_openSwapper(\n                                    static_cast<UBool>(pInfo->isBigEndian), pInfo->charsetFamily,\n                                    U_IS_BIG_ENDIAN, U_CHARSET_FAMILY,\n                                    &errorCode);\n                if(U_FAILURE(errorCode)) {\n                    fprintf(stderr, \"icupkg: udata_openSwapper(\\\"%s\\\") failed - %s\\n\",\n                            pItem->name, u_errorName(errorCode));\n                    exit(errorCode);\n                }\n\n                ds->printError=printError;\n                ds->printErrorContext=stderr;\n\n                const uint8_t *inBytes=pItem->data+itemHeaderLength;\n                int32_t length=pItem->length-itemHeaderLength;\n\n                ucnv_enumDependencies(ds, pItem->name, pInfo, inBytes, length, check, context, &errorCode);\n                udata_closeSwapper(ds);\n                break;\n            }\n        default:\n            break;\n        }\n","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/pkgitems.cpp#L601-L637","documentation":"Fatal error (calls exit) thrown when udata_openSwapper fails to create a data swapper for endian/charset conversion of a CNV-type item. The swapper is needed to normalize the converter data from the source platform's endianness/charset to the target platform's. The printed error includes the item name and the u_errorName() of the failure code.","triggerScenarios":"In Package::enumDependencies for FMT_CNV items, udata_openSwapper is called with the source pInfo->isBigEndian/charsetFamily and the target U_IS_BIG_ENDIAN/U_CHARSET_FAMILY. If it returns U_FAILURE, fprintf at pkgitems.cpp:619 fires and exit(errorCode) is called.","commonSituations":"Corrupted or truncated CNV data that confuses the swapper; invalid pInfo header with impossible endianness/charset values; memory exhaustion during swapper creation; ICU library build inconsistency between the tool and the runtime data swapper API.","solutions":["Rebuild the .cnv file from its .ucm source with makeconv to eliminate data corruption.","Verify the ICU library and icupkg tool are from the same build/version to ensure API compatibility.","Check available memory and system resources if udata_openSwapper fails with a memory-related error code."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// icupkg calls exit(); capture exit code and stderr\nresult = subprocess.run(['icupkg', 'data.dat'], capture_output=True)\nif result.returncode != 0:\n    stderr = result.stderr.decode()\n    if 'udata_openSwapper' in stderr:\n        print(f'Data swapper creation failed: {stderr}')","preventionTips":["Ensure icupkg and the ICU library are from the same build.","Rebuild .cnv files from .ucm sources with makeconv.","Check for memory and resource issues if the swapper fails with memory errors."],"tags":["icu","converter","cnv","data-swapper","endian","fatal","exit"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}