{"record":{"id":"db08e1dc0835cbdc","repo":"BabylonJS/Babylon.js","slug":"path-must-start-with-a","errorCode":null,"errorMessage":"Path must start with a /","messagePattern":"Path must start with a /","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts","lineNumber":77,"sourceCode":"     * <digit> := D+\r\n     *\r\n     * Examples:\r\n     *  - \"/nodes/0/rotation\"\r\n     * - \"/nodes.length\"\r\n     *  - \"/materials/2/emissiveFactor\"\r\n     *  - \"/materials/2/pbrMetallicRoughness/baseColorFactor\"\r\n     *  - \"/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength\"\r\n     *\r\n     * @param path The path to convert\r\n     * @returns The object and info associated with the path\r\n     */\r\n    public convert(path: string): IObjectInfo<IObjectAccessor<T, BabylonType, BabylonValue>> {\r\n        let objectTree: any = this._gltf;\r\n        let infoTree: any = this._infoTree;\r\n        let target: any = undefined;\r\n\r\n        if (!path.startsWith(\"/\")) {\r\n            throw new Error(\"Path must start with a /\");\r\n        }\r\n        const parts = path.split(\"/\");\r\n        parts.shift();\r\n\r\n        //if the last part has \".length\" in it, separate that as an extra part\r\n        if (parts[parts.length - 1].includes(\".length\")) {\r\n            const lastPart = parts[parts.length - 1];\r\n            const split = lastPart.split(\".\");\r\n            parts.pop();\r\n            parts.push(...split);\r\n        }\r\n\r\n        let ignoreObjectTree = false;\r\n\r\n        for (const part of parts) {\r\n            const isLength = part === \"length\";\r\n            if (isLength) {\r\n                // For .length, check if the current level has a 'length' accessor\r","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts#L59-L95","documentation":"gltfPathToObjectConverter.convert() walks a glTF JSON Pointer by splitting on '/'; a path not beginning with '/' would produce a bogus first segment, so the converter requires the standard leading slash and throws otherwise. This is the generic (non-Babylon) path-to-object converter used for extension targets like KHR_animation_pointer.","triggerScenarios":"convert() called with \"nodes/0/translation\", \"extensions/KHR_materials_emissive_strength/emissiveStrength\", or any pointer missing the leading '/', including empty strings and paths built by joining segments with '/' but omitting the initial one.","commonSituations":"Building paths with [\"nodes\",\"0\",\"translation\"].join(\"/\") instead of \"/\" + ...join(\"/\"); trimming whitespace or a leading slash accidentally (e.g. .replace(/^\\//, \"\")); receiving a relative reference from user config or an external tool that stores pointers without the leading slash.","solutions":["Ensure the path starts with '/', e.g. \"/nodes/0/translation\".","When building from segments, prefix the join: `/${parts.join(\"/\")}`.","If input comes from config or an external source, normalize it (trim and prepend '/') before calling convert()."],"exampleFix":"// before\nconverter.convert(\"nodes/0/translation\");\n// after\nconverter.convert(\"/nodes/0/translation\");","handlingStrategy":"validation","validationCode":"if (typeof path !== \"string\" || !path.startsWith(\"/\")) {\n  throw new Error(`glTF pointer must start with '/': ${path}`);\n}\nconverter.convert(path);","typeGuard":"function isJsonPointer(path: unknown): path is string {\n  return typeof path === \"string\" && path.startsWith(\"/\");\n}","tryCatchPattern":"try {\n  const info = converter.convert(path);\n} catch (e) {\n  if (String(e).includes(\"must start with a /\")) {\n    path = \"/\" + String(path).replace(/^\\/+/, \"\");\n  }\n}","preventionTips":["Build pointers as `/${segments.join(\"/\")}` so the leading slash is never lost","Normalize externally supplied pointers (trim, ensure leading '/') before conversion","Add a JSON Pointer format check at config-load time"],"tags":["gltf","json-pointer","path-validation"],"backgroundTag":"json-pointer-invalid-prefix","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}