ruvnet/ruflo · error

Invalid inputDim: ${this.config.inputDim}. Must be positive.

Error message

Invalid inputDim: ${this.config.inputDim}. Must be positive.

What it means

BaseGNNLayer.validateConfig() (gnn.ts:482) runs in every layer constructor and rejects non-positive inputDim. inputDim is the feature dimension of incoming node embeddings; 0 or negative values are meaningless for weight matrices, so construction fails fast instead of producing NaNs later. Note createLayer() defaults missing values to 64, so hitting this means you explicitly passed inputDim <= 0.

Source

Thrown at v3/@claude-flow/plugins/src/integrations/ruvector/gnn.ts:482

 * Abstract base class for GNN layer implementations.
 */
export abstract class BaseGNNLayer implements IGNNLayer {
  readonly type: GNNLayerType;
  readonly config: GNNLayerConfig;

  constructor(config: GNNLayerConfig) {
    this.type = config.type;
    this.config = config;
    this.validateConfig();
  }

  /**
   * Validate layer configuration.
   * @throws Error if configuration is invalid
   */
  protected validateConfig(): void {
    if (this.config.inputDim <= 0) {
      throw new Error(`Invalid inputDim: ${this.config.inputDim}. Must be positive.`);
    }
    if (this.config.outputDim <= 0) {
      throw new Error(`Invalid outputDim: ${this.config.outputDim}. Must be positive.`);
    }
    if (this.config.dropout !== undefined && (this.config.dropout < 0 || this.config.dropout > 1)) {
      throw new Error(`Invalid dropout: ${this.config.dropout}. Must be between 0 and 1.`);
    }
    if (this.config.numHeads !== undefined && this.config.numHeads <= 0) {
      throw new Error(`Invalid numHeads: ${this.config.numHeads}. Must be positive.`);
    }
  }

  abstract forward(graph: GraphData): Promise<GNNOutput>;
  abstract messagePass(nodes: NodeFeatures, edges: EdgeFeatures): Promise<NodeFeatures>;

  /**
   * Aggregate messages using the specified method.
   */

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Pass a positive integer inputDim matching your node feature size
  2. When chaining layers, wire inputDim from the previous layer's config.outputDim and assert it is > 0
  3. Let createLayer() fill defaults by omitting inputDim instead of passing 0

Example fix

// before
const layer = new GCNLayer({ type: 'gcn', inputDim: 0, outputDim: 64 }); // throws

// after
const inputDim = dataset.featureDim; // e.g. 128
if (!(inputDim > 0)) throw new TypeError(`dataset.featureDim must be positive, got ${inputDim}`);
const layer = new GCNLayer({ type: 'gcn', inputDim, outputDim: 64 });
Defensive patterns

Strategy: validation

Validate before calling

function assertGNNConfig(cfg: { inputDim?: number; outputDim?: number; dropout?: number; numHeads?: number }) {
  if (cfg.inputDim !== undefined && !(Number.isInteger(cfg.inputDim) && cfg.inputDim > 0)) {
    throw new TypeError(`inputDim must be a positive integer, got ${cfg.inputDim}`);
  }
}
assertGNNConfig(layerCfg);
const layer = registry.createLayer('gcn', layerCfg);

Type guard

function isValidDim(v: unknown): v is number {
  return typeof v === 'number' && Number.isInteger(v) && v > 0;
}

Try / catch

try {
  layer = new GCNLayer(config);
} catch (err) {
  if (err instanceof Error && err.message.includes('Invalid inputDim')) {
    config = { ...config, inputDim: dataset.featureDim };
    layer = new GCNLayer(config);
  } else throw err;
}

Prevention

When it happens

Trigger: new GCNLayer({ type: 'gcn', inputDim: 0, outputDim: 64 }); passing a computed dimension (e.g. prevLayer.outputDim) that is 0 because a previous step failed; loading layer config from JSON where inputDim is missing and defaults were bypassed by direct construction.

Common situations: Chaining layers programmatically and feeding an uninitialized dimension; config generated from another system with 0 as placeholder; off-by-one or wrong field (passing numNodes as inputDim).

Related errors


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