abhigyanpatwari/GitNexus · error · GitNexusRcError

must be a boolean or a non-negative integer (node cap; 0…

Error message

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

What it means

Terminal branch of the 'embeddings' validator: the value is neither boolean nor number, so it cannot mirror `--embeddings [limit]`. Strings like "yes"/"all" are not accepted in the rc file even though some CLIs tolerate them.

Solutions

  1. Use the unquoted boolean true/false, or a bare non-negative integer: {"embeddings": true}
  2. Remove quotes around numeric caps in JSON
  3. Prefer the nested "analyze" block only after the value shape is correct — quoting rules are the same

Example fix

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

Strategy: type-guard

Validate before calling

if (rc.embeddings !== undefined && !['boolean', 'number'].includes(typeof rc.embeddings)) {
  throw new Error(`embeddings must be boolean or number, got ${typeof rc.embeddings}`);
}

Type guard

const isEmbeddingsConfig = (v: unknown): v is boolean | number =>
  typeof v === 'boolean' || typeof v === 'number';

Try / catch

catch (err) {
  if (err instanceof GitNexusRcError && err.message.startsWith('embeddings')) {
    // unquote "true"/"5000" in the rc file
  }
}

Prevention

When it happens

Trigger: {"embeddings": "true"}, {"embeddings": "5000"}, {"embeddings": null}, or {"embeddings": []} in .gitnexusrc; typeof value is neither 'boolean' nor 'number' at analyze-config.ts:318.

Common situations: Quoting a boolean out of caution ("true" instead of true); copying a string limit from a shell snippet into JSON; YAML-style 'on'/'off' values.

Related errors


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

Appendix: source

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

          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 ac9a4e9abd)