abhigyanpatwari/GitNexus · error · GitNexusRcError

${source} entries must not be empty.

Error message

${source} entries must not be empty.

What it means

Thrown by normalizeValue() in the 'string-array' case when an entry trims to empty. Empty entries would produce empty alternations in the downstream consumer-scan RegExp and add no value, so they are rejected to surface config mistakes rather than silently ignored.

Source

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

        );
      }
      return trimmed;
    }
    case 'string-array': {
      // Generic shared validator — `source` already names the config key, so
      // messages here stay key-agnostic (no fetch-wrapper coupling in the
      // shared normalizer; #1589/#1852 review F7).
      if (!Array.isArray(value)) {
        throw new GitNexusRcError(`${source} must be an array of strings.`);
      }
      const names: string[] = [];
      for (const item of value) {
        if (typeof item !== 'string') {
          throw new GitNexusRcError(`${source} entries must all be strings.`);
        }
        const trimmed = item.trim();
        if (!trimmed) {
          throw new GitNexusRcError(`${source} entries must not be empty.`);
        }
        assertNoHiddenChars(trimmed, source);
        // Values may be interpolated into a RegExp downstream. Restrict to
        // identifier / member-access shapes so a config value can never smuggle
        // regex metacharacters into a consumer.
        if (!/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(trimmed)) {
          throw new GitNexusRcError(
            `${source} entry "${trimmed}" must be an identifier or member name ` +
              `(letters, digits, _, $, . — e.g. "client.get").`,
          );
        }
        names.push(trimmed);
      }
      if (names.length === 0) {
        throw new GitNexusRcError(`${source} must list at least one string.`);
      }
      // De-duplicate and cap to a sane bound so a pathological config cannot
      // blow up the consumer scan's alternation.

View on GitHub (pinned to d540b00184)

Solutions

  1. Remove empty or whitespace-only entries from the array.
  2. Provide real identifier-shaped strings (e.g. "client.get").
  3. If you have no wrappers, omit the key entirely.

Example fix

// before
{ "fetchWrappers": ["client.get", ""] }

// after
{ "fetchWrappers": ["client.get"] }
Defensive patterns

Strategy: validation

Validate before calling

function assertNoEmptyEntries(arr: string[], key: string): void {
  for (const item of arr) {
    if (typeof item !== 'string' || item.trim() === '') {
      throw new Error(`${key} entries must not be empty`);
    }
  }
}

Type guard

function hasNoEmptyEntries(value: unknown): boolean {
  return Array.isArray(value) && value.every((v) => typeof v === 'string' && v.trim().length > 0);
}

Prevention

When it happens

Trigger: Setting "fetchWrappers": [""], "fetchWrappers": ["client.get", " "], or "fetchWrappers": ["", "x"] in .gitnexusrc.

Common situations: A trailing comma in a hand-written JSON array that produced an empty slot; a whitespace-only placeholder; a template that left empty strings for unfilled wrappers.

Related errors


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