nodejs/node · error

An error occurred processing file

Error message

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

What it means

The catch-all processing error in processFile(): ucbuf_open returned a non-null UCharacterStream but the status is a failure (not U_FILE_ACCESS_ERROR, which is handled separately by error 778), or the stream is null with a non-file-access error. The message includes the resolved filename and the ICU error name, covering encoding problems, BOM issues, malformed input, and stream construction failures.

Solutions

  1. Pass the correct source encoding explicitly: `genrb --encoding UTF-8 root.txt`.
  2. Re-save the offending .txt as UTF-8 (with or without BOM per ICU's expectations) using a reliable editor.
  3. Read the printed u_errorName (e.g. U_UNSUPPORTED_ERROR, U_INVALID_CHAR_FOUND) to pinpoint encoding vs. parse causes.
  4. If the file is generated upstream, fix the generator rather than papering over the encoding.

Example fix

// before
genrb root.txt            # ambiguous encoding
// after
genrb --encoding UTF-8 root.txt
Defensive patterns

Strategy: validation

Validate before calling

# Preflight: confirm each source file is valid UTF-8 (or matches --encoding)
enc="${ENCODING:-UTF-8}"
for f in "$@"; do
  if [ "$enc" = "UTF-8" ] && command -v iconv >/dev/null 2>&1; then
    iconv -f UTF-8 -t UTF-8 "$src_dir/$f" >/dev/null 2>&1 || {
      echo "ERROR: $f is not valid UTF-8" >&2; exit 2; }
  fi
done

Try / catch

genrb --encoding "$enc" -s "$src_dir" "$@" 2>err.log
if grep -q 'An error occurred processing file' err.log; then
  echo "Source processing error; see err.log for the u_errorName and offending file" >&2
  exit 1
fi

Prevention

When it happens

Trigger: Source .txt in an encoding genrb cannot auto-detect and that conflicts with --encoding; missing or malformed BOM; binary garbage in a .txt; truncated UTF-8 sequences. Any UErrorCode other than U_FILE_ACCESS_ERROR coming out of ucbuf_open lands here.

Common situations: Mixing source encodings without specifying --encoding; files saved as UTF-16 without BOM; copy-pasting locale data through tools that mangle bytes; CRLF or non-character codepoints that the detector rejects.

Related errors


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

Appendix: source

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

        } else {
            openFileName.append(inputDir, status);
        }
    }
    openFileName.appendPathPart(filename, status);

    // Test for CharString failure
    if (U_FAILURE(status)) {
        return;
    }

    ucbuf.adoptInstead(ucbuf_open(openFileName.data(), &cp,getShowWarning(),true, &status));
    if(status == U_FILE_ACCESS_ERROR) {

        fprintf(stderr, "couldn't open file %s\n", openFileName.data());
        return;
    }
    if (ucbuf.isNull() || U_FAILURE(status)) {
        fprintf(stderr, "An error occurred processing file %s. Error: %s\n",
                openFileName.data(), u_errorName(status));
        return;
    }
    /* auto detected popular encodings? */
    if (cp!=nullptr && isVerbose()) {
        printf("autodetected encoding %s\n", cp);
    }
    /* Parse the data into an SRBRoot */
    data.adoptInstead(parse(ucbuf.getAlias(), inputDir, outputDir, filename,
            !omitBinaryCollation, options[NO_COLLATION_RULES].doesOccur, options[ICU4X_MODE].doesOccur, &status));

    if (data.isNull() || U_FAILURE(status)) {
        fprintf(stderr, "couldn't parse the file %s. Error:%s\n", filename, u_errorName(status));
        return;
    }

    // Run filtering before writing pool bundle
    if (filterDir != nullptr) {

View on GitHub (pinned to 1b2de5e052)