{"record":{"id":"0752e79bb41ecac6","repo":"BabylonJS/Babylon.js","slug":"error-in-provided-version-name-version","errorCode":null,"errorMessage":"Error in provided version - ${name} (${version})","messagePattern":"Error in provided version - (.+?) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/XR/webXRFeaturesManager.ts","lineNumber":564,"sourceCode":"     * @param version optional version to load. if not provided the latest version will be enabled\r\n     * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n     * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n     * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n     * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n     */\r\n    public enableFeature<T extends WebXRFeatureNameType>(\r\n        // eslint-disable-next-line @typescript-eslint/naming-convention\r\n        featureName: T | { Name: T },\r\n        version: number | string = \"latest\",\r\n        moduleOptions: ResolveWebXRFeatureOptions<T> = {} as ResolveWebXRFeatureOptions<T>,\r\n        attachIfPossible: boolean = true,\r\n        required: boolean = true\r\n    ): ResolveWebXRFeature<T> {\r\n        const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n        let versionToLoad: number;\r\n        if (typeof version === \"string\") {\r\n            if (!version) {\r\n                throw new Error(`Error in provided version - ${name} (${version})`);\r\n            }\r\n            if (version === \"stable\") {\r\n                versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n            } else if (version === \"latest\") {\r\n                versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n            } else {\r\n                // try loading the number the string represents\r\n                versionToLoad = +version;\r\n            }\r\n            if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n                throw new Error(`feature not found - ${name} (${version})`);\r\n            }\r\n        } else {\r\n            versionToLoad = version;\r\n        }\r\n\r\n        // check if there is a feature conflict\r\n        const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/XR/webXRFeaturesManager.ts#L546-L582","documentation":"enableFeature resolves a string version to a numeric version. An empty string version (falsy) can never resolve, so Babylon throws `Error in provided version - <name> (<version>)` immediately. It is a guard against passing an invalid/empty version string to the features manager.","triggerScenarios":"Calling xrSessionManager.enableFeature(featureName, \"\") — an empty-string version — from application code or from a helper (e.g. layers/enabledFeature wrappers) that propagates an unset version string.","commonSituations":"A variable holding the version is empty due to failed config lookup or env substitution; passing a dynamic version string built at runtime that ended up empty; confusing the API by passing an empty string instead of omitting the argument (default is \"latest\").","solutions":["Omit the version argument or pass \"latest\"/\"stable\" instead of an empty string.","Fix the source of the empty version variable (config/env lookup) before calling enableFeature.","Validate the version string is non-empty (and \"stable\"|\"latest\"|numeric) before calling.","Convert numeric-string versions to numbers yourself and pass a number if that is the intent."],"exampleFix":"// before\nxr.enableFeature(WebXRFeatureName.LAYERS, config.xrLayerVersion || \"\");\n// after\nconst version = config.xrLayerVersion && !isNaN(+config.xrLayerVersion)\n    ? +config.xrLayerVersion\n    : \"latest\";\nxr.enableFeature(WebXRFeatureName.LAYERS, version);","handlingStrategy":"validation","validationCode":"function assertValidVersion(name: string, version?: number | string): number | string {\n    if (typeof version === \"string\" && !version) throw new Error(`enableFeature: empty version for ${name}`);\n    return version ?? \"latest\";\n}","typeGuard":null,"tryCatchPattern":"try {\n    xr.enableFeature(featureName, version);\n} catch (e) {\n    if (String((e as Error).message).startsWith(\"Error in provided version\")) {\n    console.warn(\"Invalid version; retrying with latest\");\n    xr.enableFeature(featureName, \"latest\");\n    } else { throw e; }\n}","preventionTips":["Never pass \"\" as a version; omit it or use \"latest\"/\"stable\"","Validate dynamic version strings against /^(stable|latest|\\d+)$/ before calling","Fix config/env lookups so version variables cannot be empty","Add unit tests covering version resolution in feature-enabling helpers"],"tags":["webxr","features-manager","invalid-argument","configuration"],"backgroundTag":"invalid-feature-version","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}