{"record":{"id":"791bb8b5eb62952f","repo":"BabylonJS/Babylon.js","slug":"event-id-should-be-a-number","errorCode":null,"errorMessage":"Event id should be a number","messagePattern":"Event id should be a number","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.ts","lineNumber":313,"sourceCode":"                event: { name: \"event\" },\n            },\n            flows: {\n                out: { name: \"done\" },\n            },\n        },\n    },\n    \"event/send\": {\n        blocks: [FlowGraphBlockNames.SendCustomEvent],\n        extraProcessor(gltfBlock, declaration, _mapping, parser, serializedObjects) {\n            // set eventId and eventData. The configuration object of the glTF should have a single object.\n            // validate that we are running it on the right block.\n            if (declaration.op !== \"event/send\" || !gltfBlock.configuration || Object.keys(gltfBlock.configuration).length !== 1) {\n                throw new Error(\"Receive event should have a single configuration object, the event itself\");\n            }\n            const eventConfiguration = gltfBlock.configuration[\"event\"];\n            const eventId = eventConfiguration.value?.[0];\n            if (typeof eventId !== \"number\") {\n                throw new Error(\"Event id should be a number\");\n            }\n            const event: InteractivityEvent = parser.arrays.events[eventId];\n            const serializedObject = serializedObjects[0];\n            serializedObject.config ||= {};\n            serializedObject.config.eventId = event.eventId;\n            serializedObject.config.eventData = event.eventData;\n            return serializedObjects;\n        },\n    },\n    \"event/receive\": {\n        blocks: [FlowGraphBlockNames.ReceiveCustomEvent],\n        outputs: {\n            values: {\n                // KHR_interactivity `ref event` output (the event reference).\n                event: { name: \"event\" },\n            },\n            flows: {\n                out: { name: \"done\" },","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.ts#L295-L331","documentation":"For an event/send block, the single \"event\" configuration object must carry the event id as a number in its value array (value[0]). The loader reads eventConfiguration.value?.[0] and throws when it is missing, undefined, or of another type, because the id is used to index parser.arrays.events.","triggerScenarios":"An event/send block whose configuration.event.value array is absent, empty, or contains a non-numeric value (e.g. a string event name instead of the numeric index into the events array).","commonSituations":"Exporters writing event names instead of indices; hand-edited JSON with a removed value; schema drift between exporter and loader versions.","solutions":["Set configuration.event.value to an array containing the numeric event index, e.g. { \"value\": [2] }","Check the asset's interactivity events array and use the correct numeric index","Re-export with an up-to-date exporter that writes numeric event ids"],"exampleFix":"// before\n\"configuration\": { \"event\": { \"value\": [\"onHit\"] } }\n// after\n\"configuration\": { \"event\": { \"value\": [2] } }","handlingStrategy":"type-guard","validationCode":"function hasNumericEventId(block) {\n  return typeof block.configuration?.event?.value?.[0] === \"number\";\n}\n// check event/send blocks reference a numeric event index before loading","typeGuard":"const hasNumericEventId = (b: { configuration?: { event?: { value?: unknown[] } } }): b is { configuration: { event: { value: [number] } } } => typeof b.configuration?.event?.value?.[0] === \"number\";","tryCatchPattern":"try {\n  await loader.loadAsync(url);\n} catch (e) {\n  if (e instanceof Error && e.message === \"Event id should be a number\") {\n    console.error(\"event/send block value must be a numeric index into the events array.\");\n  } else throw e;\n}","preventionTips":["Always reference events by numeric index, never by name","Validate the interactivity events array indices in CI","Keep exporter versions aligned with the loader's schema expectations"],"tags":["gltf","interactivity","flow-graph","type-error"],"backgroundTag":"gltf-interactivity-invalid-configuration","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}