abhigyanpatwari/GitNexus · error · Error

GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer,

Error message

GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer, got "${rawRequestDims}"

What it means

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.

Source

Thrown at gitnexus/src/core/embeddings/http-client.ts:174

  if (rawDims !== undefined) {
    if (!/^\d+$/.test(rawDims)) {
      throw new Error(`${EMBEDDING_DIMS_ENV_ERROR_LEAD}, got "${rawDims}"`);
    }
    const parsed = parseInt(rawDims, 10);
    if (parsed <= 0) {
      throw new Error(`${EMBEDDING_DIMS_ENV_ERROR_LEAD}, got "${rawDims}"`);
    }
    dimensions = parsed;
  }

  const rawRequestDims = process.env.GITNEXUS_EMBEDDING_REQUEST_DIMS?.trim();
  let requestDimensions = dimensions;
  if (rawRequestDims) {
    if (/^(omit|none|off|false|0)$/i.test(rawRequestDims)) {
      requestDimensions = undefined;
    } else {
      if (!/^\d+$/.test(rawRequestDims)) {
        throw new Error(`${EMBEDDING_REQUEST_DIMS_ENV_ERROR_LEAD}, got "${rawRequestDims}"`);
      }
      const parsed = parseInt(rawRequestDims, 10);
      if (parsed <= 0) {
        throw new Error(`${EMBEDDING_REQUEST_DIMS_ENV_ERROR_LEAD}, got "${rawRequestDims}"`);
      }
      requestDimensions = parsed;
    }
  }

  return {
    baseUrl: baseUrl.replace(/\/+$/, ''),
    model,
    apiKey: process.env.GITNEXUS_EMBEDDING_API_KEY ?? 'unused',
    dimensions,
    maxAttempts: parsePositiveIntegerEnv(
      'GITNEXUS_EMBEDDING_MAX_ATTEMPTS',
      HTTP_MAX_RETRIES + 1,
      20,

View on GitHub (pinned to d540b00184)

Solutions

  1. 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.
  2. 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.
  3. Verify with `node -e "console.log(JSON.stringify(process.env.GITNEXUS_EMBEDDING_REQUEST_DIMS))"` in the indexer's environment.

Example fix

// before
export GITNEXUS_EMBEDDING_REQUEST_DIMS=auto

// after
export GITNEXUS_EMBEDDING_REQUEST_DIMS=256   # request 256d truncated vectors
// or suppress the field entirely:
export GITNEXUS_EMBEDDING_REQUEST_DIMS=omit
Defensive patterns

Strategy: validation

Validate before calling

const raw = process.env.GITNEXUS_EMBEDDING_REQUEST_DIMS?.trim();
if (raw && !/^(omit|none|off|false|0)$/i.test(raw) && !/^\d+$/.test(raw)) {
  throw new Error(`GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer, got "${raw}"`);
}

Type guard

import { isHttpEmbeddingDimsError } from 'gitnexus';
const isRequestDimsConfigError = (e: unknown): boolean =>
  e instanceof Error &&
  e.message.includes('GITNEXUS_EMBEDDING_REQUEST_DIMS must be a positive integer');

Try / catch

try {
  await httpEmbed(texts);
} catch (e) {
  if (e instanceof Error && isHttpEmbeddingDimsError(e.message)) {
    console.error('Bad GITNEXUS_EMBEDDING_REQUEST_DIMS; fix the env and restart.');
    process.exit(2);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/01cc46bd2d59124d. Report an issue: GitHub.