{"record":{"id":"01cc46bd2d59124d","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-embedding-request-dims-must-be-a-positive","errorCode":null,"errorMessage":"GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer, got \"${rawRequestDims}\"","messagePattern":"GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer, got \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/http-client.ts","lineNumber":174,"sourceCode":"  if (rawDims !== undefined) {\n    if (!/^\\d+$/.test(rawDims)) {\n      throw new Error(`${EMBEDDING_DIMS_ENV_ERROR_LEAD}, got \"${rawDims}\"`);\n    }\n    const parsed = parseInt(rawDims, 10);\n    if (parsed <= 0) {\n      throw new Error(`${EMBEDDING_DIMS_ENV_ERROR_LEAD}, got \"${rawDims}\"`);\n    }\n    dimensions = parsed;\n  }\n\n  const rawRequestDims = process.env.GITNEXUS_EMBEDDING_REQUEST_DIMS?.trim();\n  let requestDimensions = dimensions;\n  if (rawRequestDims) {\n    if (/^(omit|none|off|false|0)$/i.test(rawRequestDims)) {\n      requestDimensions = undefined;\n    } else {\n      if (!/^\\d+$/.test(rawRequestDims)) {\n        throw new Error(`${EMBEDDING_REQUEST_DIMS_ENV_ERROR_LEAD}, got \"${rawRequestDims}\"`);\n      }\n      const parsed = parseInt(rawRequestDims, 10);\n      if (parsed <= 0) {\n        throw new Error(`${EMBEDDING_REQUEST_DIMS_ENV_ERROR_LEAD}, got \"${rawRequestDims}\"`);\n      }\n      requestDimensions = parsed;\n    }\n  }\n\n  return {\n    baseUrl: baseUrl.replace(/\\/+$/, ''),\n    model,\n    apiKey: process.env.GITNEXUS_EMBEDDING_API_KEY ?? 'unused',\n    dimensions,\n    maxAttempts: parsePositiveIntegerEnv(\n      'GITNEXUS_EMBEDDING_MAX_ATTEMPTS',\n      HTTP_MAX_RETRIES + 1,\n      20,","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/http-client.ts#L156-L192","documentation":"Thrown by readConfig() when GITNEXUS_EMBEDDING_REQUEST_DIMS is set to a non-numeric, non-keyword value. Line 174 fires when the trimmed value is truthy, does not match the omit-keyword regex (omit|none|off|false|0, case-insensitive), and fails the /^\\d+$/ integer test. It is a plain Error (config mistake), recognizable via isHttpEmbeddingDimsError. Note GITNEXUS_EMBEDDING_REQUEST_DIMS controls the `dimensions` field sent in the request body (Matryoshka truncation), distinct from GITNEXUS_EMBEDDING_DIMS which declares the expected output width.","triggerScenarios":"readConfig() with GITNEXUS_EMBEDDING_REQUEST_DIMS set to a non-integer, non-keyword string such as \"auto\", \"1.5\", \"default\", \"high\", or \"many\". The keyword values omit/none/off/false/0 are accepted (they suppress the field); bare integers are accepted as the request dimension.","commonSituations":"Operator confuses the request-dims knob with the output-dims knob and writes a descriptive word. Pasting a float dimension. Copying a value from a provider doc that uses \"default\" or \"auto\". Setting it to a value supported by one provider but not understood by this client's validator.","solutions":["Set GITNEXUS_EMBEDDING_REQUEST_DIMS to a positive integer (e.g. 256) to request Matryoshka truncation, or to one of omit|none|off|false|0 to suppress the field.","If you only want to declare the expected output width and not send a request hint, leave GITNEXUS_EMBEDDING_REQUEST_DIMS unset and set GITNEXUS_EMBEDDING_DIMS instead.","Verify with `node -e \"console.log(JSON.stringify(process.env.GITNEXUS_EMBEDDING_REQUEST_DIMS))\"` in the indexer's environment."],"exampleFix":"// before\nexport GITNEXUS_EMBEDDING_REQUEST_DIMS=auto\n\n// after\nexport GITNEXUS_EMBEDDING_REQUEST_DIMS=256   # request 256d truncated vectors\n// or suppress the field entirely:\nexport GITNEXUS_EMBEDDING_REQUEST_DIMS=omit","handlingStrategy":"validation","validationCode":"const raw = process.env.GITNEXUS_EMBEDDING_REQUEST_DIMS?.trim();\nif (raw && !/^(omit|none|off|false|0)$/i.test(raw) && !/^\\d+$/.test(raw)) {\n  throw new Error(`GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer, got \"${raw}\"`);\n}","typeGuard":"import { isHttpEmbeddingDimsError } from 'gitnexus';\nconst isRequestDimsConfigError = (e: unknown): boolean =>\n  e instanceof Error &&\n  e.message.includes('GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer');","tryCatchPattern":"try {\n  await httpEmbed(texts);\n} catch (e) {\n  if (e instanceof Error && isHttpEmbeddingDimsError(e.message)) {\n    console.error('Bad GITNEXUS_EMBEDDING_REQUEST_DIMS; fix the env and restart.');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Remember GITNEXUS_EMBEDDING_REQUEST_DIMS is the request hint (sent in the body); GITNEXUS_EMBEDDING_DIMS is the expected output width — do not conflate them.","Use the keyword `omit` to suppress the request field on strict backends.","Document the accepted keyword set (omit|none|off|false|0) next to wherever you set the var."],"tags":["config","env","validation","embeddings"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}