abhigyanpatwari/GitNexus · error · GitNexusRcError

${source} must be a number or numeric string.

Error message

${source} must be a number or numeric string.

What it means

A `numeric-string` config key got a value whose JSON type is neither number nor string — e.g. a boolean, null, object, or array. The normalizer only accepts JSON numbers and numeric strings (which it forwards to the downstream per-flag range checks).

Source

Thrown at gitnexus/src/cli/analyze-config.ts:304

    case 'numeric-string': {
      // Mirror Commander's contract: these options reach the existing CLI
      // validation as strings. Accept a JSON number or a string; normalize to a
      // string and let the downstream per-flag validation enforce ranges so the
      // error messages stay in one place.
      if (typeof value === 'number') {
        if (!Number.isFinite(value)) {
          throw new GitNexusRcError(`${source} must be a finite number.`);
        }
        return String(value);
      }
      if (typeof value === 'string') {
        const trimmed = value.trim();
        if (!trimmed) {
          throw new GitNexusRcError(`${source} must not be empty.`);
        }
        return trimmed;
      }
      throw new GitNexusRcError(`${source} must be a number or numeric string.`);
    }
    case 'embeddings': {
      // Mirror `--embeddings [limit]`: boolean toggles, a non-negative integer
      // sets the node cap (normalized to a string, as Commander would supply).
      if (typeof value === 'boolean') return value;
      if (typeof value === 'number') {
        if (!Number.isInteger(value) || value < 0) {
          throw new GitNexusRcError(
            `${source} must be true/false or a non-negative integer (node cap; 0 disables the cap).`,
          );
        }
        return String(value);
      }
      throw new GitNexusRcError(
        `${source} must be a boolean or a non-negative integer (node cap; 0 disables the cap).`,
      );
    }
    default:

View on GitHub (pinned to d540b00184)

Solutions

  1. Use a JSON number or a numeric string for the key.
  2. Remove the key if you do not intend to set it.

Example fix

// before
"workers": true
// after
"workers": 8
Defensive patterns

Strategy: type-guard

Validate before calling

for (const k of ['maxFileSize','workerTimeout','walCheckpointThreshold','workers','embeddingThreads','embeddingBatchSize','embeddingSubBatchSize']) {
  const v = cfg[k];
  if (v !== undefined && typeof v !== 'number' && typeof v !== 'string') {
    throw new Error(k + ' must be a number or numeric string');
  }
}

Type guard

const isNumericStringInput = (v) =>
  v === undefined || typeof v === 'number' || typeof v === 'string';

Prevention

When it happens

Trigger: Setting { "workers": true }, { "maxFileSize": null }, or { "embeddingThreads": {} } in `.gitnexusrc`.

Common situations: Mistaking a numeric knob for a boolean toggle (e.g. workers: true); setting a value to null intending to clear it; misreading the schema and nesting an object.

Related errors


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