{"record":{"id":"548ba10e23e8c2b3","repo":"nodejs/node","slug":"collationdatawriter-writetailoring-failed-s","errorCode":null,"errorMessage":"CollationDataWriter::writeTailoring() failed: %s","messagePattern":"CollationDataWriter::writeTailoring\\(\\) failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/genrb/parse.cpp","lineNumber":1355,"sourceCode":"    int32_t indexes[icu::CollationDataReader::IX_TOTAL_SIZE + 1];\n    int32_t totalSize = icu::CollationDataWriter::writeTailoring(\n            *t, *t->settings, indexes, dest, capacity, intStatus);\n    if(intStatus == U_BUFFER_OVERFLOW_ERROR) {\n        intStatus = U_ZERO_ERROR;\n        capacity = totalSize;\n        dest = buffer.allocateInsteadAndCopy(capacity);\n        if(dest == nullptr) {\n            fprintf(stderr, \"memory allocation (%ld bytes) for file contents failed\\n\",\n                    static_cast<long>(capacity));\n            *status = U_MEMORY_ALLOCATION_ERROR;\n            res_close(result);\n            return nullptr;\n        }\n        totalSize = icu::CollationDataWriter::writeTailoring(\n                *t, *t->settings, indexes, dest, capacity, intStatus);\n    }\n    if(U_FAILURE(intStatus)) {\n        fprintf(stderr, \"CollationDataWriter::writeTailoring() failed: %s\\n\",\n                u_errorName(intStatus));\n        res_close(result);\n        return nullptr;\n    }\n    if(isVerbose()) {\n        printf(\"%s~%s collation tailoring part sizes:\\n\", state->filename, collationType);\n        icu::CollationInfo::printSizes(totalSize, indexes);\n        if(t->settings->hasReordering()) {\n            printf(\"%s~%s collation reordering ranges:\\n\", state->filename, collationType);\n            icu::CollationInfo::printReorderRanges(\n                    *t->data, t->settings->reorderCodes, t->settings->reorderCodesLength);\n        }\n#if 0  // debugging output\n    } else {\n        printf(\"%s~%s collation tailoring part sizes:\\n\", state->filename, collationType);\n        icu::CollationInfo::printSizes(totalSize, indexes);\n#endif\n    }","sourceCodeStart":1337,"sourceCodeEnd":1373,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/genrb/parse.cpp#L1337-L1373","documentation":"After successfully allocating the collation output buffer, CollationDataWriter::writeTailoring() was called a second time (with the correct buffer size) and returned a UErrorCode failure. This means the tailoring data itself is internally inconsistent — the writer could not serialize it even with adequate buffer space. This is a data-level failure, not a resource failure.","triggerScenarios":"A collation tailoring with internally inconsistent data: invalid reordering codes, contradictory rule settings, unset required fields in the CollationTailoring struct, or a tailoring whose settings do not match its base data. The first writeTailoring call computed the size, but the second call found a data problem.","commonSituations":"Custom collation rules with invalid script reordering codes; a locale's collation data that references a non-existent base collation; ICU version mismatch where the CollationDataWriter API changed; corrupted or partially-generated collation rules from a failed prior step.","solutions":["Read the u_errorName code in the message to identify the specific data error (e.g. U_ILLEGAL_ARGUMENT_ERROR, U_INVALID_FORMAT_ERROR)","Validate the collation rules in the source .txt file — check reorder codes, rule syntax, and base collation references","Compare the collation rules against the ICU CLDR source version that matches your ICU version","If using custom (non-CLDR) rules, simplify them to isolate which rule triggers the failure","Ensure the ICU data version matches the ICU library version (mismatches cause data format errors)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Validate collation rules before full genrb build\n# Check for common issues in collation rule files\nfor f in data/*.txt; do\n    # Check for valid reorder codes\n    grep -n 'reorder' \"$f\" | grep -vP 'reorder\\s*[:\\s]*(Hani|Latn|Cyrl|Grek|Hangl|Kana|Ethi|Hebr|Arab|Thaa|Deva|Beng|Guru|Gujr|Taml|Telu|Knda|Mlym|Sinh|Thai|Laoo|Khmr|Myam|Tibt|Geor|Armn|Zyyy|Zinh|Zzzz)' && echo \"Suspicious reorder code in $f\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate collation rule syntax and reorder codes against the ICU/CLDR version you are targeting","Ensure the ICU data version matches the ICU library version","Test custom collation rules in isolation before including them in a full build","Keep collation source files under version control for easy comparison"],"tags":["icu","genrb","collation","data-error","writetailoring"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}