{"record":{"id":"09f5129b53cc4888","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-max-file-size-must-be-a-positive-intege","errorCode":null,"errorMessage":"  GITNEXUS_MAX_FILE_SIZE must be a positive integer (KB), got \"${raw}\" — using default ${DEFAULT_MAX_FILE_SIZE_BYTES / 1024}KB","messagePattern":"  GITNEXUS_MAX_FILE_SIZE must be a positive integer \\(KB\\), got \"(.+?)\" — using default (.+?)KB","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/utils/max-file-size.ts","lineNumber":31,"sourceCode":"  if (warned.has(key)) return;\n  warned.add(key);\n  logger.warn(message);\n};\n\n/**\n * Resolve the effective file-size skip threshold (bytes) for the walker.\n * Reads `GITNEXUS_MAX_FILE_SIZE` (KB). Invalid values fall back to the default\n * and emit a one-time warning. Values above the tree-sitter ceiling are clamped.\n */\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","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/utils/max-file-size.ts#L13-L49","documentation":"getMaxFileSizeBytes() reads GITNEXUS_MAX_FILE_SIZE (in KB) for the walker's file-size skip threshold. A value that is not a finite positive integer (0, negatives, floats like 1.5, or strings like 10MB) is rejected: the default 512KB threshold is used instead and a one-time warning is emitted via warnOnce keyed by the raw value.","triggerScenarios":"Starting any indexing walk with GITNEXUS_MAX_FILE_SIZE set to a non-integer, non-positive, or non-numeric value; the first call to getMaxFileSizeBytes() triggers warnOnce and every later call silently uses DEFAULT_MAX_FILE_SIZE_BYTES (512 * 1024).","commonSituations":"Operators copying a size like 10MB or 1.5GB into the env var (unit suffixes are unsupported — the value is KB only), exporting 0 expecting 'no limit', stale dotfiles carrying a float, or shell-quoting mistakes.","solutions":["Set a positive integer in KB, e.g. GITNEXUS_MAX_FILE_SIZE=2048 for 2MB","If you intended 'no limit', remember values above the tree-sitter ceiling are clamped, not honored — check the clamp warning instead","Confirm the banner printed at startup reflects the effective threshold you expect","Unset the variable if the default 512KB is acceptable and you only wanted the noise gone"],"exampleFix":"# before\nexport GITNEXUS_MAX_FILE_SIZE=10MB   # invalid → warn, effective 512KB\n# after\nexport GITNEXUS_MAX_FILE_SIZE=10240   # 10MB in KB, honored","handlingStrategy":"validation","validationCode":"// Validate before the walk starts:\nconst raw = process.env.GITNEXUS_MAX_FILE_SIZE;\nif (raw !== undefined && !/^\\d+$/.test(raw)) {\n  throw new Error(`GITNEXUS_MAX_FILE_SIZE must be an integer KB count, got: ${raw}`);\n}","typeGuard":"function isKbInteger(raw: string | undefined): raw is string {\n  return raw !== undefined && /^\\d+$/.test(raw) && Number(raw) > 0;\n}","tryCatchPattern":null,"preventionTips":["Always express the value as integer KB (2048, not 2MB / 2.0 / 2048KB)","Assert the startup banner's effective threshold matches your intent before large runs","Prefer unset (512KB default) over guessed values when unsure"],"tags":["configuration","environment-variable","file-size","walker"],"backgroundTag":"invalid-env-var","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"}