{"record":{"id":"59b739e090e3735e","repo":"BabylonJS/Babylon.js","slug":"babylonscenepathtoobjectconverter-path-path-59b739","errorCode":null,"errorMessage":"BabylonScenePathToObjectConverter: path \"${path}\" is missing an instance id.","messagePattern":"BabylonScenePathToObjectConverter: path \"(.+?)\" is missing an instance id\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts","lineNumber":152,"sourceCode":"        const parts = tail.split(\"/\").filter((p) => p.length > 0);\r\n        if (parts.length === 0) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: path \"${path}\" is missing a collection name.`);\r\n        }\r\n\r\n        const collectionName = parts[0];\r\n        const collection = (this._tree as unknown as Record<string, IBabylonObjectCollection<any> | undefined>)[collectionName];\r\n        if (!collection) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: unknown collection \"${collectionName}\" in path \"${path}\".`);\r\n        }\r\n\r\n        // Handle `<collection>.length` (no instance lookup).\r\n        if (parts.length === 2 && parts[1] === \"length\") {\r\n            const arr = this._getCollectionArray(collectionName);\r\n            return { object: arr, info: collection.length as AnyAccessor };\r\n        }\r\n\r\n        if (parts.length < 2) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: path \"${path}\" is missing an instance id.`);\r\n        }\r\n\r\n        // parseInt would accept \"12abc\" as 12; require an all-digits id so a malformed path fails\r\n        // loudly instead of binding to the wrong instance.\r\n        if (!/^\\d+$/.test(parts[1])) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: invalid uniqueId \"${parts[1]}\" in path \"${path}\".`);\r\n        }\r\n        const uniqueId = parseInt(parts[1], 10);\r\n        if (!Number.isFinite(uniqueId) || uniqueId < 0) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: invalid uniqueId \"${parts[1]}\" in path \"${path}\".`);\r\n        }\r\n\r\n        const instance = this._lookupInstanceByUniqueId(collectionName, uniqueId);\r\n        if (!instance) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: no ${collectionName} instance found with uniqueId ${uniqueId} (path \"${path}\").`);\r\n        }\r\n\r\n        // No property after the id → the ref itself is just a handle to the instance.\r","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts#L134-L170","documentation":"Beyond the special '<collection>.length' form, resolving an instance requires at least a second segment: the instance's uniqueId. If the path stops after the collection name (only one segment remains), there is no id to look up, so the library throws. This distinguishes collection-level references from the instance/property references the converter is designed to resolve.","triggerScenarios":"convert() called with a path like \"/extensions/BABYLON_scene_objects/transformNodes\" (collection only, no id, and not the \"/length\" form); a builder that omitted the id segment.","commonSituations":"Wanting a handle to a whole collection and assuming the converter supports it (it only supports '<collection>.length'); path truncation when the id variable was empty; confusing the generic glTF path converter's semantics with this one.","solutions":["Append the instance uniqueId (and optionally the property) to the path, e.g. \".../transformNodes/42\" or \".../transformNodes/42/position\".","If you need the collection size, use the '<collection>.length' form instead, e.g. \".../transformNodes/length\".","Guard the path builder to refuse emitting a pointer with fewer than two segments after the prefix."],"exampleFix":"// before\nconverter.convert(`${prefix}transformNodes`); // missing id\n// after\nconverter.convert(`${prefix}transformNodes/42/position`);","handlingStrategy":"validation","validationCode":"const parts = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length).split(\"/\").filter(Boolean);\nif (parts.length === 1) {\n  throw new Error(`Pointer needs an instance id (or use '<collection>.length'): ${path}`);\n}\nconverter.convert(path);","typeGuard":"function hasInstanceId(path: string): boolean {\n  const parts = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length).split(\"/\").filter(Boolean);\n  return parts.length === 2 && parts[1] === \"length\" || parts.length >= 2;\n}","tryCatchPattern":"try {\n  const info = converter.convert(path);\n} catch (e) {\n  // collection-only pointer; use '<collection>.length' or append the id\n}","preventionTips":["For collection sizes always use the '<collection>.length' form","Refuse to emit pointers with fewer than two segments after the prefix","Check that id variables are non-empty before interpolation"],"tags":["gltf","json-pointer","babylon","path-validation"],"backgroundTag":"json-pointer-missing-segment","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}