{"record":{"id":"426269ad7cd21c54","repo":"nodejs/node","slug":"u-invalid-char-found","errorCode":"U_INVALID_CHAR_FOUND","errorMessage":"icupkg/ures_enumDependencies(%s res=%08x) alias string contains non-invariant characters\\n","messagePattern":"icupkg/ures_enumDependencies\\((.+?) res=%08x\\) alias string contains non-invariant characters\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/pkgitems.cpp","lineNumber":229,"sourceCode":"    }\n    checkIDSuffix(itemName, parent, parentLength, suffix, check, context, pErrorCode);\n}\n\n// get dependencies from resource bundles ---------------------------------- ***\n\nstatic const char16_t SLASH=0x2f;\n\n/*\n * Check for the alias from the string or alias resource res.\n */\nstatic void\ncheckAlias(const char *itemName,\n           Resource res, const char16_t *alias, int32_t length, UBool useResSuffix,\n           CheckDependency check, void *context, UErrorCode *pErrorCode) {\n    int32_t i;\n\n    if(!uprv_isInvariantUString(alias, length)) {\n        fprintf(stderr, \"icupkg/ures_enumDependencies(%s res=%08x) alias string contains non-invariant characters\\n\",\n                        itemName, res);\n        *pErrorCode=U_INVALID_CHAR_FOUND;\n        return;\n    }\n\n    // extract the locale ID from alias strings like\n    // locale_ID/key1/key2/key3\n    // locale_ID\n\n    // search for the first slash\n    for(i=0; i<length && alias[i]!=SLASH; ++i) {}\n\n    if(res_getPublicType(res)==URES_ALIAS) {\n        // ignore aliases with an initial slash:\n        // /ICUDATA/... and /pkgname/... go to a different package\n        // /LOCALE/... are for dynamic sideways fallbacks and don't go to a fixed bundle\n        if(i==0) {\n            return; // initial slash ('/')","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/pkgitems.cpp#L211-L247","documentation":"checkAlias validates that a resource-bundle alias string uses only invariant characters; if uprv_isInvariantUString fails it prints the item name + resource handle and sets *pErrorCode = U_INVALID_CHAR_FOUND (returns, does not exit). Alias strings must be invariant so they can be safely byte-swapped and matched.","triggerScenarios":"A .res resource contains an alias with non-ASCII or otherwise non-invariant characters; a corrupt resource bundle where alias data is damaged. The guard is the first check in checkAlias.","commonSituations":"Hand-edited or corrupt locale resource data with bad alias entries; a .res produced by tooling that wrote non-invariant bytes into an alias; encoding corruption during transfer.","solutions":["Regenerate the offending .res from the source locale XML/txt with current genrb.","Audit aliases for non-invariant characters: any byte > 0x7F or control char in an alias is invalid.","Do not hand-edit compiled .res files; edit source and recompile.","Run the ICU data build cleanly from a trusted source tree."],"exampleFix":"# before: alias contains a non-invariant char (e.g. a raw UTF-8 byte)\n# in source locale data the alias was edited to include non-ASCII\ngenrb bad.txt   # produces a .res with a non-invariant alias\n# after: fix the alias in source to use only invariant (ASCII) characters\ngenrb fixed.txt","handlingStrategy":"validation","validationCode":"// C++: validate alias bytes are invariant before relying on them\n#include \"unicode/utypes.h\"\nbool aliasIsSafe(const char16_t *alias, int32_t len) {\n    return uprv_isInvariantUString(alias, len);  // false => would trigger U_INVALID_CHAR_FOUND\n}","typeGuard":"// narrows an alias to 'safe to swap/match' before use\nbool isInvariantAlias(const char16_t *alias, int32_t len) {\n    return alias != nullptr && len >= 0 && uprv_isInvariantUString(alias, len);\n}","tryCatchPattern":"// checkAlias sets *pErrorCode; caller must test it after enumerating deps\nUErrorCode err = U_ZERO_ERROR;\nures_enumDependencies(..., &err);\nif (err == U_INVALID_CHAR_FOUND) { /* a non-invariant alias was found; rebuild the .res */ }","preventionTips":["Edit locale source (.txt) and recompile with genrb; never hand-edit compiled .res.","Keep alias strings ASCII/invariant only.","Run a dependency-enumeration pass and check for U_INVALID_CHAR_FOUND before shipping data.","Regenerate suspect .res from a trusted source tree."],"tags":["icu","icupkg","resource-bundle","data-validation","build-tools"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}