abhigyanpatwari/GitNexus · error · GitNexusRcError

${source} must be a string.

Error message

${source} must be a string.

What it means

Thrown by normalizeValue() in the 'string' case (for keys like name, embeddingBaseUrl, embeddingModel, embeddingDevice) when the .gitnexusrc value is not a JSON string. After the type check the value is trimmed, checked for emptiness, hidden characters, and Markdown-significant characters in turn.

Source

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

  switch (kind) {
    case 'boolean':
      if (typeof value !== 'boolean') {
        throw new GitNexusRcError(`${source} must be a boolean (true/false).`);
      }
      return value;
    case 'boolean-negate':
      if (typeof value !== 'boolean') {
        throw new GitNexusRcError(`${source} must be a boolean (true/false).`);
      }
      return !value;
    case 'branch':
      if (typeof value !== 'string') {
        throw new GitNexusRcError(`${source} must be a string branch name.`);
      }
      return validateBranchName(value, source);
    case 'string': {
      if (typeof value !== 'string') {
        throw new GitNexusRcError(`${source} must be a string.`);
      }
      const trimmed = value.trim();
      if (!trimmed) {
        throw new GitNexusRcError(`${source} must not be empty.`);
      }
      assertNoHiddenChars(trimmed, source);
      // `name` flows into the generated AGENTS.md/CLAUDE.md as `**${name}**` and
      // inside `gitnexus://repo/${name}/…` code spans, so a Markdown-significant
      // character would break those spans or inject emphasis/links/HTML into
      // agent-instruction content (#1996 tri-review P1). `_` is intentionally
      // allowed (legitimate in repo names; intraword `_` is not emphasis).
      // embeddingDevice (the other `string`-kind option) only ever holds a
      // fixed device token, so this guard never rejects a valid value there.
      if (/[`*[\]<>]/.test(trimmed)) {
        throw new GitNexusRcError(
          `${source} must not contain Markdown-significant characters (\` * [ ] < >).`,
        );
      }

View on GitHub (pinned to d540b00184)

Solutions

  1. Quote the value: "name": "my-repo", "embeddingBaseUrl": "http://localhost:11434".
  2. Omit the key if you do not need to override the default.
  3. Check the value type with a JSON linter before committing.

Example fix

// before
{ "name": 42, "embeddingBaseUrl": true }

// after
{ "name": "my-repo", "embeddingBaseUrl": "http://localhost:11434" }
Defensive patterns

Strategy: type-guard

Validate before calling

function assertConfigString(value: unknown, key: string): void {
  if (typeof value !== 'string') {
    throw new Error(`${key} must be a string, got ${typeof value}`);
  }
}

Type guard

function isConfigString(value: unknown): value is string {
  return typeof value === 'string';
}

Prevention

When it happens

Trigger: Setting "name": 42, "embeddingBaseUrl": true, "name": null, or "embeddingModel": ["x"] in .gitnexusrc.

Common situations: A repo name set as a number; an embedding URL set as a boolean by mistake; a config generator that produced the wrong JSON type for a field.

Related errors


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