{"record":{"id":"bc01c9c6fd7a72f8","repo":"BabylonJS/Babylon.js","slug":"aggregate-blocks-should-not-be-prepared-for-runtim","errorCode":null,"errorMessage":"Aggregate blocks should not be prepared for runtime.","messagePattern":"Aggregate blocks should not be prepared for runtime\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/blockFoundation/aggregateBlock.ts","lineNumber":35,"sourceCode":"     * The class name of the block.\r\n     */\r\n    public static override ClassName = \"AggregateBlock\";\r\n\r\n    /**\r\n     * The list of relationships between the internal graph output and the outside ones.\r\n     */\r\n    private readonly _aggregatedOutputs: [ConnectionPoint, ConnectionPoint][] = [];\r\n\r\n    /**\r\n     * The list of relationships between the internal graph inputs and the outside ones.\r\n     */\r\n    private readonly _aggregatedInputs: [ConnectionPoint[], ConnectionPoint][] = [];\r\n\r\n    /**\r\n     * Do not override prepareForRuntime for aggregate blocks. It is not supported.\r\n     */\r\n    public override prepareForRuntime(): never {\r\n        throw new Error(\"Aggregate blocks should not be prepared for runtime.\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     * Merges the internal graph into the SmartFilter\r\n     */\r\n    public _mergeIntoSmartFilter(mergedAggregateBlocks: AggregateBlock[]): void {\r\n        // Rewire output connections\r\n        for (const [internalConnectionPoint, externalConnectionPoint] of this._aggregatedOutputs) {\r\n            const endpointsToConnectTo = externalConnectionPoint.endpoints.slice();\r\n            externalConnectionPoint.disconnectAllEndpoints();\r\n            for (const endpoint of endpointsToConnectTo) {\r\n                internalConnectionPoint.connectTo(endpoint);\r\n            }\r\n        }\r\n\r\n        // Rewire input connections\r\n        for (const [internalConnectionPoints, externalConnectionPoint] of this._aggregatedInputs) {\r","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/blockFoundation/aggregateBlock.ts#L17-L53","documentation":"AggregateBlock represents a sub-graph of blocks and has no standalone runtime representation. prepareForRuntime is intentionally overridden to always throw, because merging the internal graph happens through the aggregate-specific mechanism instead.","triggerScenarios":"Calling prepareForRuntime() directly on any block whose class extends AggregateBlock (e.g. CustomAggregateBlock), or calling it generically over all blocks in a filter without skipping aggregates.","commonSituations":"Iterating filter.blocks and calling prepareForRuntime on each; custom block subclasses incorrectly overriding prepareForRuntime on an aggregate; framework code that assumes every block is runtime-preparable.","solutions":["Skip aggregate blocks in your loop: only call prepareForRuntime on non-aggregate blocks (check via getClassName or instanceof).","Let the SmartFilter runtime merge aggregate sub-filters automatically via the internal merge path instead of preparing them manually.","If you wrote a custom aggregate block, do not override prepareForRuntime; extend the aggregate registration API instead."],"exampleFix":"// before\nfor (const block of filter.blocks) block.prepareForRuntime();\n// after\nfor (const block of filter.blocks) {\n    if (!(block instanceof AggregateBlock)) block.prepareForRuntime();\n}","handlingStrategy":"type-guard","validationCode":"if (block instanceof AggregateBlock) {\n    // skip — aggregate blocks merge via the internal graph, not prepareForRuntime\n} else {\n    block.prepareForRuntime();\n}","typeGuard":"function isNotAggregate(block: BaseBlock): block is Exclude<BaseBlock, AggregateBlock> {\n    return !(block instanceof AggregateBlock);\n}","tryCatchPattern":"try {\n    block.prepareForRuntime();\n} catch (e) {\n    if (e instanceof Error && e.message.includes('Aggregate blocks should not be prepared')) {\n        // ignore: aggregates are merged by the SmartFilter runtime\n    } else throw e;\n}","preventionTips":["Never iterate all blocks calling prepareForRuntime unconditionally.","Check instanceof AggregateBlock (or getClassName) before runtime preparation.","Do not override prepareForRuntime in aggregate block subclasses."],"tags":["smart-filters","runtime","unsupported-operation"],"backgroundTag":"unsupported-operation-for-block-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}