abhigyanpatwari/GitNexus · error

Analysis feature "${descriptor.id}" has invalid version ${de

Error message

Analysis feature "${descriptor.id}" has invalid version ${descriptor.version}

What it means

An `AnalysisFeatureDescriptor`'s `version` is not a safe positive integer: it is NaN, fractional, zero, negative, or beyond Number.MAX_SAFE_INTEGER. Versions are part of the rebuild-vs-incremental contract — when a feature's output semantics change, the version is bumped so older indexes are detected as needing a rebuild.

Source

Thrown at gitnexus/src/core/analysis-features.ts:33

export const CLASS_FRAMEWORK_ANNOTATIONS_FEATURE: AnalysisFeatureDescriptor = {
  id: 'graph.class-framework-annotations',
  version: 1,
  appliesTo: () => true,
};

/** Resolve the exact feature set this build promises for the supplied files. */
export function resolveAnalysisFeatureVersions(
  descriptors: readonly AnalysisFeatureDescriptor[],
  filePaths: readonly string[],
): Record<string, number> {
  const resolved = new Map<string, number>();
  const seenIds = new Set<string>();
  for (const descriptor of descriptors) {
    if (descriptor.id.trim().length === 0) {
      throw new Error('Analysis feature descriptor id must not be empty');
    }
    if (!Number.isSafeInteger(descriptor.version) || descriptor.version < 1) {
      throw new Error(
        `Analysis feature "${descriptor.id}" has invalid version ${descriptor.version}`,
      );
    }
    if (seenIds.has(descriptor.id)) {
      throw new Error(`Duplicate analysis feature descriptor: ${descriptor.id}`);
    }
    seenIds.add(descriptor.id);
    if (!descriptor.appliesTo(filePaths)) continue;
    resolved.set(descriptor.id, descriptor.version);
  }

  return Object.fromEntries([...resolved].sort(([left], [right]) => left.localeCompare(right)));
}

/**
 * Compare an untrusted metadata value with the exact capabilities produced by
 * this build. Extra keys also mismatch: a rollback must rebuild instead of
 * certifying graph semantics emitted only by a newer binary.

View on GitHub (pinned to d540b00184)

Solutions

  1. Set `version` to an integer >= 1.
  2. Bump the integer (2, 3, ...) whenever the feature's emitted graph semantics change.
  3. Keep versions as literal integers in the descriptor, never computed from floats.

Example fix

// before
{ id: 'graph.x', version: 0, appliesTo: () => true }
// after
{ id: 'graph.x', version: 1, appliesTo: () => true }
Defensive patterns

Strategy: validation

Validate before calling

for (const d of descriptors) {
  if (!Number.isSafeInteger(d.version) || d.version < 1) {
    throw new Error('feature "' + d.id + '" has invalid version ' + d.version);
  }
}

Type guard

const hasValidVersion = (d) =>
  Number.isSafeInteger(d.version) && d.version >= 1;

Prevention

When it happens

Trigger: Registering { id: 'graph.x', version: 0, ... }, version: 1.5, or version: -1.

Common situations: Starting version numbering at 0 instead of 1; using a semantic-version float like 1.2; computing the version from an expression that can yield NaN.

Related errors


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