nodejs/node · error

U_ILLEGAL_ARGUMENT_ERROR

U_ILLEGAL_ARGUMENT_ERROR

Error message

icupkg: \"%s\" is not recognized as a package filename (must end with .dat)\n

What it means

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.

Source

Thrown at deps/icu-small/source/tools/toolutil/package.cpp:186

        return -1;
    }

    return makeTypeEnum(pInfo->charsetFamily, static_cast<UBool>(pInfo->isBigEndian));
}

// file handling ----------------------------------------------------------- ***

static void
extractPackageName(const char *filename,
                   char pkg[], int32_t capacity) {
    const char *basename;
    int32_t len;

    basename=findBasename(filename);
    len = static_cast<int32_t>(strlen(basename)) - 4; /* -4: subtract the length of ".dat" */

    if(len<=0 || 0!=strcmp(basename+len, ".dat")) {
        fprintf(stderr, "icupkg: \"%s\" is not recognized as a package filename (must end with .dat)\n",
                         basename);
        exit(U_ILLEGAL_ARGUMENT_ERROR);
    }

    if(len>=capacity) {
        fprintf(stderr, "icupkg: the package name \"%s\" is too long (>=%ld)\n",
                         basename, static_cast<long>(capacity));
        exit(U_ILLEGAL_ARGUMENT_ERROR);
    }

    memcpy(pkg, basename, len);
    pkg[len]=0;
}

static int32_t
getFileLength(FILE *f) {
    int32_t length;

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Ensure the argument ends with '.dat' (e.g. icudt67l.dat).
  2. Rename or regenerate the package file so it carries the .dat suffix.
  3. Double-check the script that builds the icupkg command line.
  4. If packaging custom data, use icupkg -a to build a correctly-named .dat.

Example fix

# before: wrong extension
icupkg -l mydata.res

# after: .dat package filename
icupkg -l mydata.dat
Defensive patterns

Strategy: type-guard

Validate before calling

// Reject filenames that won't pass extractPackageName before calling icupkg.
#include <string.h>
bool isDatPackage(const char *fn) {
    size_t n = strlen(fn);
    return n > 4 && strcmp(fn + n - 4, ".dat") == 0;
}

Type guard

// Type guard: narrows a string to a valid icupkg .dat package filename.
function isIcuDatPackage(fn: string): fn is string {
  return fn.length > 4 && fn.endsWith('.dat');
}

Prevention

When it happens

Trigger: 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.

Common situations: Passing a .zip, .res, or source file to icupkg by mistake; a script that drops the .dat extension; a typo in the filename argument.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/52c913049eb88ce6. Report an issue: GitHub.