abhigyanpatwari/GitNexus · error · GitNexusRcError

${source} must be a boolean or a non-negative integer (node

Error message

${source} must be a boolean or a non-negative integer (node cap; 0 disables the cap).

What it means

The `embeddings` config key got a value whose JSON type is neither boolean nor number — e.g. a string, null, object, or array. Unlike the `numeric-string` keys, `embeddings` does NOT accept numeric strings; it mirrors Commander's optional `[limit]` shape which is boolean or integer only.

Source

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

          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:
      // Exhaustive — kept for forward-compat if a new kind is added.
      throw new GitNexusRcError(`${source}: unsupported config value kind.`);
  }
};

/**
 * Normalize one level (flat top-level or the nested `analyze` block) into a
 * partial `AnalyzeOptions`. Rejects unknown keys and two aliases that configure
 * the same option at the same level.
 */
const normalizeLevel = (
  obj: Record<string, unknown>,
  { allowNestedKey }: { allowNestedKey: boolean },
): Partial<AnalyzeOptions> => {

View on GitHub (pinned to d540b00184)

Solutions

  1. Pass a JSON boolean or a JSON number (non-negative integer).
  2. Remove the key to use the default.

Example fix

// before
"embeddings": "100"
// after
"embeddings": 100
Defensive patterns

Strategy: type-guard

Validate before calling

const v = cfg.embeddings;
if (v !== undefined && typeof v !== 'boolean' && typeof v !== 'number') {
  throw new Error('embeddings must be a boolean or a non-negative integer');
}

Type guard

const isEmbeddingsInput = (v) =>
  v === undefined || typeof v === 'boolean' || typeof v === 'number';

Prevention

When it happens

Trigger: Setting { "embeddings": "100" } (string), { "embeddings": null }, or { "embeddings": [] } in `.gitnexusrc`.

Common situations: Assuming `embeddings` accepts a string limit like the workers/maxFileSize keys; quoting the integer out of habit; setting null to clear.

Related errors


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