ruvnet/ruflo · error · Error

invalid CIDR: ${cidr}

Error message

invalid CIDR: ${cidr}

What it means

parseCidr rejects a mesh subnet string that does not match the strict IPv4 CIDR form a.b.c.d/M (regex ^(\d{1,3})\.{3}\d{1,3}/\d{1,2}$). Fires on malformed input such as missing /M, IPv6 addresses, or stray characters — ADR-111 v1 is IPv4-only inside the mesh, so anything unparseable is refused before octet/prefix range checks run.

Source

Thrown at v3/@claude-flow/plugin-agent-federation/src/domain/value-objects/wg-config.ts:84

  const privRaw = privDer.subarray(privDer.length - 32);
  const pubRaw = pubDer.subarray(pubDer.length - 32);
  if (privRaw.length !== 32 || pubRaw.length !== 32) {
    throw new Error(`generateWgKeyPair: unexpected DER layout (priv=${privRaw.length}B pub=${pubRaw.length}B)`);
  }
  return {
    publicKey: pubRaw.toString('base64'),
    privateKey: privRaw.toString('base64'),
    createdAt: new Date().toISOString(),
  };
}

/**
 * Parse a `a.b.c.d/M` CIDR into a numeric base + mask-prefix-length.
 * Limited to IPv4 — v1 of ADR-111 is IPv4-only inside the mesh.
 */
function parseCidr(cidr: string): { base: number; prefix: number } {
  const m = cidr.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/);
  if (!m) throw new Error(`invalid CIDR: ${cidr}`);
  const [, a, b, c, d, p] = m;
  const octets = [a, b, c, d].map(Number);
  const prefix = Number(p);
  if (octets.some(o => o < 0 || o > 255) || prefix < 0 || prefix > 32) {
    throw new Error(`out-of-range CIDR: ${cidr}`);
  }
  const base = ((octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | octets[3]) >>> 0;
  return { base, prefix };
}

function ipToString(n: number): string {
  return `${(n >>> 24) & 0xff}.${(n >>> 16) & 0xff}.${(n >>> 8) & 0xff}.${n & 0xff}`;
}

/**
 * Derive a deterministic mesh IP for `nodeId` inside `subnet`.
 *
 * Strategy: sha256(nodeId) → top bytes interpreted as host portion of the

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Pass a well-formed CIDR such as '10.0.0.0/24'.
  2. Validate CIDR syntax at configuration load time before constructing value objects.
Defensive patterns

Strategy: validation

When it happens

Trigger: A CIDR string fails parsing in the wg-config value object.

Common situations: Typo'd CIDR, missing prefix length, or an address family mismatch in mesh configuration.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/ddfe63ea45178d5e. Report an issue: GitHub.