{"record":{"id":"30c32e79f7cc7413","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-max-file-size-parsed-kb-exceeds-tree","errorCode":null,"errorMessage":"  GITNEXUS_MAX_FILE_SIZE=${parsed}KB exceeds tree-sitter ceiling (${MAX_FILE_SIZE_UPPER_BOUND_BYTES / 1024}KB) — clamping","messagePattern":"  GITNEXUS_MAX_FILE_SIZE=(.+?)KB exceeds tree-sitter ceiling \\((.+?)KB\\) — clamping","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/utils/max-file-size.ts","lineNumber":40,"sourceCode":" */\nexport const getMaxFileSizeBytes = (): number => {\n  const raw = process.env.GITNEXUS_MAX_FILE_SIZE;\n  if (!raw) return DEFAULT_MAX_FILE_SIZE_BYTES;\n\n  const parsed = Number(raw);\n  if (!Number.isFinite(parsed) || parsed <= 0 || !Number.isInteger(parsed)) {\n    warnOnce(\n      `invalid:${raw}`,\n      `  GITNEXUS_MAX_FILE_SIZE must be a positive integer (KB), got \"${raw}\" — using default ${DEFAULT_MAX_FILE_SIZE_BYTES / 1024}KB`,\n    );\n    return DEFAULT_MAX_FILE_SIZE_BYTES;\n  }\n\n  const bytes = parsed * 1024;\n  if (bytes > MAX_FILE_SIZE_UPPER_BOUND_BYTES) {\n    warnOnce(\n      `clamp:${raw}`,\n      `  GITNEXUS_MAX_FILE_SIZE=${parsed}KB exceeds tree-sitter ceiling (${MAX_FILE_SIZE_UPPER_BOUND_BYTES / 1024}KB) — clamping`,\n    );\n    return MAX_FILE_SIZE_UPPER_BOUND_BYTES;\n  }\n  return bytes;\n};\n\n/**\n * Build the CLI banner message announcing an active file-size override.\n * Returns `null` when the effective threshold equals the default — the caller\n * should print nothing in that case. The returned message reflects the\n * *effective* post-clamp threshold, not the raw env value, so operators reading\n * startup output see the actual configuration the walker will use.\n */\nexport const getMaxFileSizeBannerMessage = (): string | null => {\n  const effectiveBytes = getMaxFileSizeBytes();\n  if (effectiveBytes === DEFAULT_MAX_FILE_SIZE_BYTES) return null;\n  const effectiveKb = effectiveBytes / 1024;\n  const defaultKb = DEFAULT_MAX_FILE_SIZE_BYTES / 1024;","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/utils/max-file-size.ts#L22-L58","documentation":"A valid GITNEXUS_MAX_FILE_SIZE (positive integer KB) whose byte value exceeds the tree-sitter parser buffer ceiling (MAX_FILE_SIZE_UPPER_BOUND_BYTES = TREE_SITTER_MAX_BUFFER) is clamped down to that ceiling with a one-time warnOnce. The effective threshold the walker uses is always the post-clamp value, which the CLI banner also reflects.","triggerScenarios":"Setting GITNEXUS_MAX_FILE_SIZE to a KB value whose parsed * 1024 bytes exceeds the tree-sitter max buffer (e.g. hundreds of MB trying to 'index everything'); getMaxFileSizeBytes() returns the ceiling instead.","commonSituations":"Operators attempting to disable the size skip by entering a huge number; repos containing minified bundles or generated data files larger than the parser ceiling, where the assumption is that raising the limit enough will index them — it cannot beyond the native buffer size.","solutions":["Keep the value at or below the tree-sitter ceiling shown in the message; larger inputs cannot be parsed anyway","Split or exclude the oversized artifacts (vendored bundles, lockfile-scale JSON, generated data) from indexing instead of raising the limit","Read the startup banner to verify the effective post-clamp threshold matches what you planned","If you genuinely need huge files parsed, reduce the files' size at the source — no env can raise the native ceiling"],"exampleFix":"# before\nexport GITNEXUS_MAX_FILE_SIZE=1048576   # 1GB → exceeds ceiling, clamped with warn\n# after\nexport GITNEXUS_MAX_FILE_SIZE=8192      # 8MB, under ceiling, no clamp","handlingStrategy":"validation","validationCode":"// Pre-clamp yourself so the effective value is explicit:\nconst TREE_SITTER_CEILING_KB = 64 * 1024; // keep in sync with the ceiling in the warn\nconst wanted = Number(process.env.GITNEXUS_MAX_FILE_SIZE ?? 512);\nprocess.env.GITNEXUS_MAX_FILE_SIZE = String(Math.min(wanted, TREE_SITTER_CEILING_KB));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never try to disable the size limit via a huge value — the native buffer ceiling wins","Exclude oversized generated artifacts from indexing instead of raising the cap past the ceiling","Read the banner: it shows the post-clamp effective threshold, which is what the walker uses"],"tags":["configuration","environment-variable","tree-sitter","file-size","clamping"],"backgroundTag":"config-value-clamped","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}