BabylonJS/Babylon.js · error · Error

`Target block ${connection.inputBlock} not found`

Error message

`Target block ${connection.inputBlock} not found`

What it means

Symmetric to the source-side lookup: the connection's input (target) block is resolved by name or id, and if no block matches connection.inputBlock the connection cannot be wired and deserialization throws. It indicates a dangling reference in the serialized graph's target side.

Source

Thrown at packages/dev/smartFilters/src/serialization/smartFilterDeserializer.ts:106

        // Deserialize the connections
        serializedSmartFilter.connections.forEach((connection: ISerializedConnectionV1) => {
            // Find the source block and its connection point's connectTo function
            const sourceBlock = typeof connection.outputBlock === "string" ? blockNameMap.get(connection.outputBlock) : blockIdMap.get(connection.outputBlock);

            if (!sourceBlock) {
                throw new Error(`Source block ${connection.outputBlock} not found`);
            }
            const sourceConnectionPoint = sourceBlock.outputs.find((output) => output.name === connection.outputConnectionPoint);
            if (!sourceConnectionPoint || typeof sourceConnectionPoint.connectTo !== "function") {
                throw new Error(`Block ${connection.outputBlock} does not have an connection point named ${connection.outputConnectionPoint}`);
            }
            const sourceConnectToFunction = sourceConnectionPoint.connectTo.bind(sourceConnectionPoint);

            // Find the target block and its connection point
            const targetBlock = typeof connection.inputBlock === "string" ? blockNameMap.get(connection.inputBlock) : blockIdMap.get(connection.inputBlock);
            if (!targetBlock) {
                throw new Error(`Target block ${connection.inputBlock} not found`);
            }

            const targetConnectionPoint = targetBlock.inputs.find((input) => input.name === connection.inputConnectionPoint);
            if (!targetConnectionPoint || typeof targetConnectionPoint !== "object") {
                throw new Error(`Block ${connection.inputBlock} does not have a connection point named ${connection.inputConnectionPoint}`);
            }

            // Create the connection
            sourceConnectToFunction.call(sourceBlock, targetConnectionPoint);
        });

        return smartFilter;
    }

    private async _deserializeBlockV1Async(
        smartFilter: SmartFilter,
        serializedBlock: ISerializedBlockV1,
        engine: ThinEngine,

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Fix connection.inputBlock to match an existing deserialized block's name (string) or uniqueId (number).
  2. Remove orphaned connection entries pointing at deleted blocks.
  3. Re-export from the editor rather than editing JSON by hand.
  4. Pre-validate that every connection's inputBlock exists in the blocks array before deserializing.
  5. If blocks failed earlier (error 864), register them — their absence cascades into these lookup errors.

Example fix

// before
{ "inputBlock": 42, "inputConnectionPoint": "a", ... } // id 42 not in blocks
// after
{ "inputBlock": 37, "inputConnectionPoint": "a", ... } // matches a deserialized block id
Defensive patterns

Strategy: validation

Validate before calling

function validateTargetBlocks(serialized) {
  const map = new Map(serialized.blocks.flatMap((b) => [[b.name, b], [b.uniqueId, b]]));
  for (const c of serialized.connections) {
    if (!map.has(c.inputBlock)) throw new Error(`Connection references missing inputBlock: ${c.inputBlock}`);
  }
}

Type guard

function targetBlockExists(conn, blocks) {
  const map = new Map(blocks.flatMap((b) => [[b.name, b], [b.uniqueId, b]]));
  return map.has(conn.inputBlock);
}

Try / catch

try {
  const filter = await SmartFilterDeserializer.DeserializeAsync(runtime, container, json);
} catch (e) {
  if (/Target block .+ not found/.test(e.message)) {
    throw new Error("Filter JSON has a connection to a missing target block — repair or re-export");
  }
  throw e;
}

Prevention

When it happens

Trigger: A serialized connection references an inputBlock that was never deserialized — block removed from the blocks array, name/id renamed in hand-edited JSON, or ids from a different filter pasted in.

Common situations: Hand-editing or programmatically merging .smartfilter files, deleting blocks in the editor while connections remained, version migrations that changed block naming schemes.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/8f9b2544d2339453. Report an issue: GitHub.