abhigyanpatwari/GitNexus · warning

[cobol-processor] Skipping oversized file (${(file.content.l

Error message

[cobol-processor] Skipping oversized file (${(file.content.length / 1024 / 1024).toFixed(1)}MB > ${(MAX_COBOL_FILE_SIZE / 1024 / 1024).toFixed(0)}MB): ${file.path}

What it means

The COBOL processor guards against OOM by skipping any program file whose content length exceeds MAX_COBOL_FILE_SIZE — 5 MiB by default, overridable via GITNEXUS_MAX_COBOL_FILE_SIZE_BYTES (raw bytes; invalid or non-positive values fall back to 5 MiB). The file is skipped entirely: no node processing, no preprocessing, no COPY expansion for it.

Source

Thrown at gitnexus/src/core/ingestion/cobol-processor.ts:187

    const cached = preprocessedCopyCache.get(copyPath);
    if (cached !== undefined) return cached;
    const content = copybookByPath.get(copyPath);
    if (!content) return null; // preserves original falsy→null (missing/empty)
    const preprocessed = preprocessCobolSource(content);
    preprocessedCopyCache.set(copyPath, preprocessed);
    return preprocessed;
  };

  // Track module names for cross-program CALL resolution
  const moduleNodeIds = new Map<string, string>(); // uppercase program name -> node id

  // ── 3. Process each COBOL program ──────────────────────────────────
  const raw = parseInt(process.env.GITNEXUS_MAX_COBOL_FILE_SIZE_BYTES ?? '', 10);
  const MAX_COBOL_FILE_SIZE = Number.isFinite(raw) && raw > 0 ? raw : 5 * 1024 * 1024;
  for (const file of programs) {
    // File-size guard: skip excessively large files to prevent OOM
    if (file.content.length > MAX_COBOL_FILE_SIZE) {
      logger.warn(
        `[cobol-processor] Skipping oversized file (${(file.content.length / 1024 / 1024).toFixed(1)}MB > ${(MAX_COBOL_FILE_SIZE / 1024 / 1024).toFixed(0)}MB): ${file.path}`,
      );
      continue;
    }
    const fileNodeId = generateId('File', file.path);
    // Skip if file node doesn't exist (structure-processor creates it)
    if (!graph.getNode(fileNodeId)) continue;

    // Preprocess: clean patch markers
    const cleaned = preprocessCobolSource(file.content);

    // Expand COPY statements
    const { expandedContent, copyResolutions } = expandCopies(
      cleaned,
      file.path,
      resolveCopy,
      readCopy,
    );

View on GitHub (pinned to aac7515d2a)

Solutions

  1. Raise the cap if memory allows: export GITNEXUS_MAX_COBOL_FILE_SIZE_BYTES=20971520 (20 MiB)
  2. Split the oversized member into one program per file
  3. Exclude the file from indexing if it is not needed

Example fix

# before
# default cap 5 MiB; big.cbl (12 MiB) is skipped

# after
export GITNEXUS_MAX_COBOL_FILE_SIZE_BYTES=20971520
node .gitnexus/run.cjs analyze --index-only
Defensive patterns

Strategy: validation

Validate before calling

import { statSync } from 'node:fs';

const cap = (() => {
  const raw = parseInt(process.env.GITNEXUS_MAX_COBOL_FILE_SIZE_BYTES ?? '', 10);
  return Number.isFinite(raw) && raw > 0 ? raw : 5 * 1024 * 1024;
})();
const oversized = cobolFiles.filter((f) => statSync(f).size > cap);
if (oversized.length > 0) {
  console.warn(`will be skipped (>${cap} bytes): ${oversized.join(', ')}`);
  // decide: raise the env cap, split the member, or exclude these files
}

Type guard

function isWithinCobolCap(sizeBytes: number, cap = 5 * 1024 * 1024): boolean {
  return sizeBytes <= cap;
}

Prevention

When it happens

Trigger: A COBOL source larger than the cap — often a single member concatenating many programs or a generated file; or the env var set lower than a legitimate file's size.

Common situations: Mainframe exports with many programs per member; generated COBOL; environments that set GITNEXUS_MAX_COBOL_FILE_SIZE_BYTES conservatively and then index large legacy members.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20). Data as JSON: /api/errors/e8d7ffb18802cec6. Report an issue: GitHub.