{"record":{"id":"52c913049eb88ce6","repo":"nodejs/node","slug":"u-illegal-argument-error-52c913","errorCode":"U_ILLEGAL_ARGUMENT_ERROR","errorMessage":"icupkg: \\\"%s\\\" is not recognized as a package filename (must end with .dat)\\n","messagePattern":"icupkg: \\\\\"(.+?)\\\\\" is not recognized as a package filename \\(must end with \\.dat\\)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/package.cpp","lineNumber":186,"sourceCode":"        return -1;\n    }\n\n    return makeTypeEnum(pInfo->charsetFamily, static_cast<UBool>(pInfo->isBigEndian));\n}\n\n// file handling ----------------------------------------------------------- ***\n\nstatic void\nextractPackageName(const char *filename,\n                   char pkg[], int32_t capacity) {\n    const char *basename;\n    int32_t len;\n\n    basename=findBasename(filename);\n    len = static_cast<int32_t>(strlen(basename)) - 4; /* -4: subtract the length of \".dat\" */\n\n    if(len<=0 || 0!=strcmp(basename+len, \".dat\")) {\n        fprintf(stderr, \"icupkg: \\\"%s\\\" is not recognized as a package filename (must end with .dat)\\n\",\n                         basename);\n        exit(U_ILLEGAL_ARGUMENT_ERROR);\n    }\n\n    if(len>=capacity) {\n        fprintf(stderr, \"icupkg: the package name \\\"%s\\\" is too long (>=%ld)\\n\",\n                         basename, static_cast<long>(capacity));\n        exit(U_ILLEGAL_ARGUMENT_ERROR);\n    }\n\n    memcpy(pkg, basename, len);\n    pkg[len]=0;\n}\n\nstatic int32_t\ngetFileLength(FILE *f) {\n    int32_t length;\n","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/package.cpp#L168-L204","documentation":"In extractPackageName (package.cpp/icupkg), the supplied filename's basename is checked: its length minus 4 must be positive and the last 4 chars must be '.dat'. If not, icupkg rejects the name as not a package file and exits with U_ILLEGAL_ARGUMENT_ERROR. The package name is the basename without the .dat extension.","triggerScenarios":"Calling icupkg with a filename whose basename does not end in '.dat', or whose name is exactly '.dat' or shorter (len<=0 after subtracting 4). The check runs before any package content is read.","commonSituations":"Passing a .zip, .res, or source file to icupkg by mistake; a script that drops the .dat extension; a typo in the filename argument.","solutions":["Ensure the argument ends with '.dat' (e.g. icudt67l.dat).","Rename or regenerate the package file so it carries the .dat suffix.","Double-check the script that builds the icupkg command line.","If packaging custom data, use icupkg -a to build a correctly-named .dat."],"exampleFix":"# before: wrong extension\nicupkg -l mydata.res\n\n# after: .dat package filename\nicupkg -l mydata.dat","handlingStrategy":"type-guard","validationCode":"// Reject filenames that won't pass extractPackageName before calling icupkg.\n#include <string.h>\nbool isDatPackage(const char *fn) {\n    size_t n = strlen(fn);\n    return n > 4 && strcmp(fn + n - 4, \".dat\") == 0;\n}","typeGuard":"// Type guard: narrows a string to a valid icupkg .dat package filename.\nfunction isIcuDatPackage(fn: string): fn is string {\n  return fn.length > 4 && fn.endsWith('.dat');\n}","tryCatchPattern":null,"preventionTips":["Always pass a .dat filename to icupkg.","Use icupkg -a to build packages with the correct extension.","Guard the filename with a suffix check before invoking icupkg.","Double-check generated command lines for dropped extensions."],"tags":["icu","toolutil","package","icupkg","input-validation","u-illegal-argument-error"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}