{"record":{"id":"c7e0ae4d09259db5","repo":"BabylonJS/Babylon.js","slug":"babylonscenepathtoobjectconverter-path-path-c7e0ae","errorCode":null,"errorMessage":"BabylonScenePathToObjectConverter: path \"${path}\" is missing a collection name.","messagePattern":"BabylonScenePathToObjectConverter: path \"(.+?)\" is missing a collection name\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts","lineNumber":136,"sourceCode":"        private _scene: Scene,\r\n        private _tree: IBabylonSceneObjectModelTree\r\n    ) {}\r\n\r\n    /**\r\n     * @param path the full JSON Pointer (must start with the Babylon prefix)\r\n     * @returns an object-info container holding the resolved instance and accessor\r\n     */\r\n    public convert(path: string): IObjectInfo<IObjectAccessor> {\r\n        if (!path.startsWith(BABYLON_SCENE_OBJECT_MODEL_PREFIX)) {\r\n            throw new Error(`BabylonScenePathToObjectConverter: path \"${path}\" does not start with the expected prefix \"${BABYLON_SCENE_OBJECT_MODEL_PREFIX}\".`);\r\n        }\r\n\r\n        // Strip the namespace prefix and split. Ignore trailing empty segments\r\n        // so refs of the form \"/extensions/BABYLON_scene_objects/transformNodes/42/\" parse cleanly.\r\n        const tail = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length);\r\n        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","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts#L118-L154","documentation":"After stripping the Babylon namespace prefix, convert() splits the remainder into '/'-separated segments and filters out empty ones. If nothing remains, there is no collection name to resolve, so the library throws. This catches paths that consist solely of the prefix (or prefix plus slashes), which carry no information about which scene-object collection to look up.","triggerScenarios":"Calling convert() with exactly BABYLON_SCENE_OBJECT_MODEL_PREFIX, the prefix plus a trailing '/', or an empty/prefix-only string produced by a builder that failed to append the collection and id segments.","commonSituations":"Path-template interpolation where the collection/id variables were empty or undefined (e.g. `${prefix}${collection}/${id}` with undefined values coerced oddly); truncating a pointer during string processing; a serializer emitting the namespace but no payload.","solutions":["Ensure the full pointer includes at least '<collection>/<uniqueId>' after the prefix, e.g. \"/extensions/BABYLON_scene_objects/transformNodes/42\".","Check the code that builds the path: log the collection and id values before interpolation and confirm neither is empty/undefined.","Add a guard that skips (rather than converts) refs shorter than prefix + two segments."],"exampleFix":"// before\nconst path = `${BABYLON_SCENE_OBJECT_MODEL_PREFIX}`; // empty tail\n// after\nconst path = `${BABYLON_SCENE_OBJECT_MODEL_PREFIX}transformNodes/${node.uniqueId}/position`;","handlingStrategy":"validation","validationCode":"const tail = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length).split(\"/\").filter((p) => p.length > 0);\nif (tail.length < 2) {\n  throw new Error(`Pointer needs <collection>/<id>: ${path}`);\n}\nconverter.convert(path);","typeGuard":"function hasCollectionAndId(path: string): boolean {\n  const parts = path.slice(BABYLON_SCENE_OBJECT_MODEL_PREFIX.length).split(\"/\").filter((p) => p.length > 0);\n  return parts.length >= 2;\n}","tryCatchPattern":"try {\n  const info = converter.convert(path);\n} catch (e) {\n  // prefix-only/empty pointer; drop the reference and continue\n}","preventionTips":["Never build paths from possibly-undefined collection/id variables without a check","Assert pointer segment count >= 2 after the prefix in path-builder unit tests","Log interpolated path templates during development"],"tags":["gltf","json-pointer","babylon","path-validation"],"backgroundTag":"json-pointer-empty-path","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}