abhigyanpatwari/GitNexus · error · GitNexusRcError

must be true/false or a non-negative integer (node cap; 0…

Error message

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

What it means

The 'embeddings' option mirrors the CLI's `--embeddings [limit]`: true/false toggles it, and a non-negative integer caps embedding nodes (0 disables the cap). This variant fires on the number branch: the value is a JSON number but is fractional or negative.

Solutions

  1. Use true to enable with defaults, or a whole number cap: {"embeddings": 5000} (0 means no cap)
  2. For fractional intent, round to the nearest integer node cap
  3. Remember the normalized string is range-checked downstream — keep the cap within the flag's documented bounds

Example fix

// before (.gitnexusrc)
{"embeddings": 1.5}
// after
{"embeddings": true}
Defensive patterns

Strategy: validation

Validate before calling

const emb = rc.embeddings;
if (typeof emb === 'number' && (!Number.isInteger(emb) || emb < 0)) {
  throw new Error('embeddings must be true/false or a non-negative integer');
}

Type guard

const isEmbeddingsValue = (v: unknown): v is boolean | number =>
  typeof v === 'boolean' || (typeof v === 'number' && Number.isInteger(v) && v >= 0);

Try / catch

catch (err) {
  if (err instanceof GitNexusRcError && err.message.includes('non-negative integer')) {
    // round the cap or use a boolean toggle
  }
}

Prevention

When it happens

Trigger: {"embeddings": 1.5} or {"embeddings": -1} in .gitnexusrc; Number.isInteger(value) is false or value < 0 at analyze-config.ts:312.

Common situations: Trying to express a ratio or 'all' as a number; typos like -1 meaning 'unlimited'; float division results pasted from a calculator or script.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-08-20). Data as JSON: /api/errors/d7df10555dfb5f01. Report an issue: GitHub.

Appendix: source

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

        }
        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:
      // 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

View on GitHub (pinned to ac9a4e9abd)