{"record":{"id":"b05b7d3d4e5baafa","repo":"abhigyanpatwari/GitNexus","slug":"name-must-be-a-positive-integer-got-raw","errorCode":null,"errorMessage":"${name} must be a positive integer, got \"${raw}\"","messagePattern":"(.+?) must be a positive integer, got \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/http-client.ts","lineNumber":56,"sourceCode":"  maxAttempts: number;\n  retryCapMs: number;\n  minIntervalMs: number;\n  timeoutMs: number;\n  requestDimensions?: number;\n}\n\nexport interface EmbeddingRequestOptions {\n  signal?: AbortSignal;\n}\n\nlet lastHttpRequestStartedAt: number | undefined;\nlet httpPaceQueue: Promise<void> = Promise.resolve();\n\nconst parsePositiveIntegerEnv = (name: string, fallback: number, max: number): number => {\n  const raw = process.env[name];\n  if (raw === undefined || raw === '') return fallback;\n  if (!/^\\d+$/u.test(raw)) {\n    throw new Error(`${name} must be a positive integer, got \"${raw}\"`);\n  }\n  const parsed = Number(raw);\n  if (!Number.isSafeInteger(parsed) || parsed <= 0 || parsed > max) {\n    throw new Error(`${name} must be a positive integer <= ${max}, got \"${raw}\"`);\n  }\n  return parsed;\n};\n\nconst parseNonNegativeIntegerEnv = (name: string, fallback: number, max: number): number => {\n  const raw = process.env[name];\n  if (raw === undefined || raw === '') return fallback;\n  if (!/^\\d+$/u.test(raw)) {\n    throw new Error(`${name} must be a non-negative integer, got \"${raw}\"`);\n  }\n  const parsed = Number(raw);\n  if (!Number.isSafeInteger(parsed) || parsed < 0 || parsed > max) {\n    throw new Error(`${name} must be a non-negative integer <= ${max}, got \"${raw}\"`);\n  }","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/http-client.ts#L38-L74","documentation":"Thrown by parsePositiveIntegerEnv() in http-client.ts when an HTTP-mode embedding env var it owns (GITNEXUS_EMBEDDING_MAX_ATTEMPTS, GITNEXUS_EMBEDDING_RETRY_CAP_MS, GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS) is set to a value that fails the /^\\d+$/u regex — i.e. contains any non-digit character. The regex-level check fires before the numeric range check (error 116), catching negatives (-1 has a leading -), decimals (1.5), and junk (abc) with a clear 'must be a positive integer' message naming the offending variable.","triggerScenarios":"readConfig() calls parsePositiveIntegerEnv for the three HTTP tuning vars at http-client.ts:189-204. Fires only when GITNEXUS_EMBEDDING_URL and GITNEXUS_EMBEDDING_MODEL are both set (readConfig returns null otherwise). Examples: GITNEXUS_EMBEDDING_MAX_ATTEMPTS=-1, =1.5, =3x, =abc.","commonSituations":"Using a negative value to mean 'unlimited' (not supported — use the max cap); a unit suffix from copy-paste (300s, 5x); a float timeout from a computed config; a YAML that coerced the value to a string with surrounding quotes/whitespace.","solutions":["Set the named env var to a plain positive integer string of digits only.","Unset it to accept the documented default (attempts 3, retry cap 5000ms, timeout 180000ms).","If you wanted unlimited attempts, use a large finite value within the per-variable max instead of a negative."],"exampleFix":"# before\nexport GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS=300s\n# after\nexport GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS=300000","handlingStrategy":"validation","validationCode":"const assertDigitsOnly = (name: string): void => {\n  const v = process.env[name];\n  if (v !== undefined && v !== '' && !/^\\d+$/u.test(v)) {\n    throw new Error(`${name} must be a positive-integer string of digits only; got \\\"${v}\\\"`);\n  }\n};\n['GITNEXUS_EMBEDDING_MAX_ATTEMPTS', 'GITNEXUS_EMBEDDING_RETRY_CAP_MS', 'GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS']\n  .forEach(assertDigitsOnly);","typeGuard":"const isDigitsOnly = (v: string | undefined): boolean =>\n  v === undefined || v === '' || /^\\d+$/u.test(v);","tryCatchPattern":null,"preventionTips":["Set HTTP tuning env vars as bare positive integers (no units, no signs, no decimals).","Use a preflight env validation step in CI to catch malformed values.","Unset a variable rather than setting 0 or a negative to disable it."],"tags":["config","env-var","embeddings","http-mode","validation"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}