{"record":{"id":"6b202e83abee2ea1","repo":"BabylonJS/Babylon.js","slug":"was-asked-to-serialize-an-unrecognized-block-type-6b202e","errorCode":null,"errorMessage":"Was asked to serialize an unrecognized block type","messagePattern":"Was asked to serialize an unrecognized block type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/blockFoundation/inputBlock.serializer.ts","lineNumber":139,"sourceCode":" * @param inputBlock - The Vector2 InputBlock to serialize\r\n * @returns The serialized data for the InputBlock\r\n */\r\nfunction SerializeVector2InputBlock(inputBlock: InputBlock<ConnectionPointType.Vector2>): Vector2InputBlockData {\r\n    return {\r\n        inputType: ConnectionPointType.Vector2,\r\n        value: inputBlock.runtimeValue.value,\r\n        appMetadata: inputBlock.appMetadata,\r\n    };\r\n}\r\n\r\n/**\r\n * The V1 serializer for an InputBlock\r\n */\r\nexport const InputBlockSerializer: IBlockSerializerV1 = {\r\n    blockType: InputBlockBase.ClassName,\r\n    serialize: (block: BaseBlock) => {\r\n        if (block.blockType !== InputBlockBase.ClassName) {\r\n            throw new Error(\"Was asked to serialize an unrecognized block type\");\r\n        }\r\n        return {\r\n            name: block.name,\r\n            uniqueId: block.uniqueId,\r\n            blockType: InputBlockBase.ClassName,\r\n            namespace: null,\r\n            comments: block.comments,\r\n            data: SerializeInputBlockData(block as unknown as InputBlockBase),\r\n        };\r\n    },\r\n};\r\n","sourceCodeStart":121,"sourceCodeEnd":151,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/blockFoundation/inputBlock.serializer.ts#L121-L151","documentation":"InputBlockSerializer is registered for blocks whose blockType equals InputBlockBase.ClassName. Its serialize() first asserts the passed block actually has that blockType, and throws this error when asked to serialize some other block. It is an internal invariant check: block dispatch should have routed the block to a different serializer.","triggerScenarios":"Passing a non-input BaseBlock (e.g. a ShaderBlock or operator block) directly to InputBlockSerializer.serialize, or registering it as the serializer for another block type in a custom serialization setup.","commonSituations":"Writing a custom block and mistakenly wiring InputBlockSerializer as its serializer; calling the serializer manually instead of going through SmartFilter.serialize; a block subclass that changed/overrode ClassName.","solutions":["Verify block.blockType equals InputBlockBase.ClassName before invoking this serializer.","Use SmartFilter.serialize / the block registry dispatch instead of calling InputBlockSerializer.serialize directly.","Register the correct serializer for your custom block type."],"exampleFix":"// before\nconst data = InputBlockSerializer.serialize(myShaderBlock);\n// after\nconst data = myShaderBlock.blockType === InputBlockBase.ClassName\n    ? InputBlockSerializer.serialize(myShaderBlock)\n    : BlockSerializerDispatch(myShaderBlock);","handlingStrategy":"type-guard","validationCode":"if (!(block instanceof InputBlockBase)) {\n  throw new TypeError(\"Expected an InputBlock to serialize\");\n}","typeGuard":"function isInputBlock(b: BaseBlock): b is InputBlockBase {\n  return b.blockType === InputBlockBase.ClassName;\n}","tryCatchPattern":"try {\n  const data = InputBlockSerializer.serialize(block);\n} catch {\n  // fall back to the block-type registry dispatch\n  const data = SmartFilterSerializer.serializeBlock(block);\n}","preventionTips":["Always serialize through the SmartFilter/block-registry dispatch, not serializers directly.","Register one serializer per blockType and verify ClassName is not overridden in subclasses.","Unit-test custom block registration to confirm dispatch finds the right serializer."],"tags":["serialization","type-mismatch","wrong-dispatch"],"backgroundTag":"serializer-block-type-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}