{"record":{"id":"d8f5bafccbb32bee","repo":"BabylonJS/Babylon.js","slug":"babylonscenepathtoobjectconverter-invalid-uniquei","errorCode":null,"errorMessage":"BabylonScenePathToObjectConverter: invalid uniqueId \"${parts[1]}\" in path \"${path}\".","messagePattern":"BabylonScenePathToObjectConverter: invalid uniqueId \"(.+?)\" in path \"(.+?)\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts","lineNumber":158,"sourceCode":"        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\n        // The accessor's `get` and `getTarget` both return the instance.\r\n        if (parts.length === 2) {\r\n            return {\r\n                object: instance,\r\n                info: this._buildIdentityAccessor(instance),\r\n            };\r","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/babylonScenePathToObjectConverter.ts#L140-L176","documentation":"Instance ids must be all-digit strings: the converter deliberately rejects parseInt-style leniency (which would accept \"12abc\" as 12) so a malformed path fails loudly instead of binding to the wrong instance. Any second segment that is not ^\\d+$ throws this error. A finite, non-negative check follows, but non-numeric input is caught by the regex.","triggerScenarios":"convert() called with a non-numeric id segment such as \".../transformNodes/abc/position\", \".../transformNodes/12abc\", an empty-but-present segment, a name-based id, or a negative number like \"-3\".","commonSituations":"Using a node name or glTF node index string where a Babylon uniqueId is required; ids polluted by suffixes from templating; passing a UUID or stringified object key; locales/formatters injecting separators (e.g. \"1,234\").","solutions":["Pass the Babylon object's numeric uniqueId (instance.uniqueId) as a plain digit string, not a name or glTF index.","Sanitize/validate the id with /^\\d+$/.test(id) before building the path; strip any non-digit suffixes introduced by string building.","If you only have a glTF node index, resolve it to the Babylon instance first (via the loader's node mapping) and use its uniqueId."],"exampleFix":"// before\nconverter.convert(`${prefix}transformNodes/${node.name}/position`); // name, not id\n// after\nconverter.convert(`${prefix}transformNodes/${node.uniqueId}/position`);","handlingStrategy":"validation","validationCode":"const id = String(instance.uniqueId);\nif (!/^\\d+$/.test(id)) {\n  throw new Error(`uniqueId must be all digits, got: ${id}`);\n}\nconverter.convert(`${BABYLON_SCENE_OBJECT_MODEL_PREFIX}transformNodes/${id}/position`);","typeGuard":"function isValidUniqueIdSegment(id: string): id is string {\n  return /^\\d+$/.test(id);\n}","tryCatchPattern":"try {\n  const info = converter.convert(path);\n} catch (e) {\n  // non-numeric id segment; re-derive path from instance.uniqueId\n}","preventionTips":["Always source ids from instance.uniqueId, not names or glTF indices","Validate id segments with /^\\d+$/ before path construction","Never concatenate formatted/locale-aware numbers into pointers"],"tags":["gltf","json-pointer","babylon","invalid-identifier"],"backgroundTag":"invalid-unique-id","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}