abhigyanpatwari/GitNexus · error · GitNexusRcError

${source} must not be empty.

Error message

${source} must not be empty.

What it means

Thrown by normalizeValue() in the 'string' case when the value is a string but trims to empty. Repo names and embedding URLs flow into generated content and downstream config, so an empty value would produce broken output (e.g. an empty **${name}** in AGENTS.md).

Source

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

      }
      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 (\` * [ ] < >).`,
        );
      }
      return trimmed;
    }
    case 'string-array': {
      // Generic shared validator — `source` already names the config key, so

View on GitHub (pinned to d540b00184)

Solutions

  1. Provide a non-empty, non-whitespace value.
  2. Remove the key entirely to accept the default behavior.
  3. Trim surrounding whitespace in the source value before committing.

Example fix

// before
{ "name": "   " }

// after
{ "name": "my-repo" }
Defensive patterns

Strategy: validation

Validate before calling

function assertNonEmptyString(value: unknown, key: string): void {
  if (typeof value !== 'string' || value.trim() === '') {
    throw new Error(`${key} must not be empty`);
  }
}

Type guard

function isNonEmptyConfigString(value: unknown): value is string {
  return typeof value === 'string' && value.trim().length > 0;
}

Prevention

When it happens

Trigger: Setting "name": "", "name": " ", "embeddingBaseUrl": " ", or "embeddingModel": "" in .gitnexusrc.

Common situations: A config template with an empty placeholder; clearing a value by setting it to empty rather than removing the key; a whitespace-only value from a copy-paste.

Related errors


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