nodejs/node · error

An error occurred processing file %s. Error: %s

Error message

An error occurred processing file %s. Error: %s

What it means

During collation rule import, ucbuf_open returned a non-null failure code other than U_FILE_ACCESS_ERROR, or returned a null UCHARBUF pointer. This is the generic processing-error counterpart to error 784: the file was found but could not be read or decoded. The error message includes the specific u_errorName for diagnosis.

Source

Thrown at deps/icu-small/source/tools/genrb/parse.cpp:767

            if(inputDir[dirlen-1] != U_FILE_SEP_CHAR) {
                openFileName.append(U_FILE_SEP_CHAR, errorCode);
            }
        }
    }
    openFileName.append(filename, errorCode);
    if(U_FAILURE(errorCode)) {
        return;
    }
    // printf("GenrbImporter::getRules(%s, %s) reads %s\n", localeID, collationType, openFileName.data());
    const char* cp = "";
    LocalUCHARBUFPointer ucbuf(
            ucbuf_open(openFileName.data(), &cp, getShowWarning(), true, &errorCode));
    if(errorCode == U_FILE_ACCESS_ERROR) {
        fprintf(stderr, "couldn't open file %s\n", openFileName.data());
        return;
    }
    if (ucbuf.isNull() || U_FAILURE(errorCode)) {
        fprintf(stderr, "An error occurred processing file %s. Error: %s\n", openFileName.data(), u_errorName(errorCode));
        return;
    }

    /* Parse the data into an SRBRoot */
    LocalPointer<SRBRoot> data(
            parse(ucbuf.getAlias(), inputDir, outputDir, filename.data(), false, false, false, &errorCode));
    if (U_FAILURE(errorCode)) {
        return;
    }

    struct SResource *root = data->fRoot;
    struct SResource *collations = resLookup(root, "collations");
    if (collations != nullptr) {
      struct SResource *collation = resLookup(collations, collationType);
      if (collation != nullptr) {
        struct SResource *sequence = resLookup(collation, "Sequence");
        if (sequence != nullptr && sequence->isString()) {
          // No string pointer aliasing so that we need not hold onto the resource bundle.

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Read the u_errorName code in the message to identify the specific failure (e.g. U_INVALID_CHAR_FOUND = encoding issue)
  2. Check the file is not empty or truncated: `wc -c <filename>`
  3. Verify encoding and BOM: `file --mime-encoding <filename>` and `xxd <filename> | head -1`
  4. If the encoding is wrong, add or fix the BOM, or convert the file to UTF-8
  5. Re-download or re-checkout the file from source control to eliminate corruption
Defensive patterns

Strategy: validation

Validate before calling

# Validate file encoding and integrity before genrb processes it
FILE="./data/en_US.txt"
# Check file is not empty
[ -s "$FILE" ] || echo "ERROR: $FILE is empty"
# Check encoding
ENC=$(file --mime-encoding "$FILE" | awk '{print $NF}')
echo "Encoding: $ENC"
# Check for BOM
xxd "$FILE" | head -1 | grep -q 'efbb bf' && echo "Has UTF-8 BOM" || echo "No BOM"
# Validate UTF-8 if claimed
[ "$ENC" = "utf-8" ] && iconv -f UTF-8 -t UTF-8 "$FILE" > /dev/null 2>&1 || echo "ERROR: invalid UTF-8"

Prevention

When it happens

Trigger: ucbuf_open succeeds in finding the file but fails during encoding detection or BOM processing (U_INVALID_CHAR_FOUND, U_UNSUPPORTED_ERROR); the file is empty or truncated; the detected encoding is unsupported; or the UCHARBUF allocation fails internally. This is the catch-all for ucbuf_open failures that are not simple file-not-found.

Common situations: File corrupted during git transfer or copy; encoding mismatch (file is Shift-JIS but auto-detected as UTF-8); empty file left by a failed previous build step; BOM corruption; ICU version mismatch where encoding detection behavior changed.

Related errors


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