{"record":{"id":"c41f67e51e61e745","repo":"BabylonJS/Babylon.js","slug":"unknown-animation-group-loading-mode-value-anim","errorCode":null,"errorMessage":"Unknown animation group loading mode value '${animationGroupLoadingMode}'","messagePattern":"Unknown animation group loading mode value '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Loading/sceneLoader.ts","lineNumber":1269,"sourceCode":"                    animationGroup.dispose();\r\n                }\r\n                break;\r\n            case SceneLoaderAnimationGroupLoadingMode.Stop:\r\n                for (const animationGroup of scene.animationGroups) {\r\n                    animationGroup.stop();\r\n                }\r\n                break;\r\n            case SceneLoaderAnimationGroupLoadingMode.Sync:\r\n                for (const animationGroup of scene.animationGroups) {\r\n                    animationGroup.reset();\r\n                    animationGroup.restart();\r\n                }\r\n                break;\r\n            case SceneLoaderAnimationGroupLoadingMode.NoSync:\r\n                // nothing to do\r\n                break;\r\n            default:\r\n                throw new Error(\"Unknown animation group loading mode value '\" + animationGroupLoadingMode + \"'\");\r\n        }\r\n    }\r\n\r\n    const startingIndexForNewAnimatables = scene.animatables.length;\r\n\r\n    const container = await loadAssetContainerCoreAsync(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions);\r\n\r\n    container.mergeAnimationsTo(scene, scene.animatables.slice(startingIndexForNewAnimatables), targetConverter);\r\n    container.dispose();\r\n    scene.onAnimationFileImportedObservable.notifyObservers(scene);\r\n}\r\n\r\n/**\r\n * Import animations from a file into a scene\r\n * @param source a string that defines the name of the scene file, or starts with \"data:\" following by the stringified version of the scene, or a File object, or an ArrayBufferView\r\n * @param scene is the instance of BABYLON.Scene to append to\r\n * @param options an object that configures aspects of how the scene is loaded\r\n * @returns A promise that resolves when the animations are imported\r","sourceCodeStart":1251,"sourceCodeEnd":1287,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Loading/sceneLoader.ts#L1251-L1287","documentation":"When loading animations you can specify animationGroupLoadingMode, which must be one of the SceneLoaderAnimationGroupLoadingMode enum values. Any other value falls through the switch's default case and throws.","triggerScenarios":"Passing a raw number that isn't a valid enum member (e.g. 4, -1, or a value from a wrong enum) as options.animationGroupLoadingMode to ImportAnimationsAsync/LoadAnimationGroupAsync.","commonSituations":"Storing the mode in config as an arbitrary number; value came from JSON or an any-typed variable bypassing TypeScript; copying a constant from another enum.","solutions":["Use SceneLoaderAnimationGroupLoadingMode members (Sync, SyncAlways, NoSync) instead of raw numbers","Validate the value is in the enum before calling, or fall back to a known member","Fix config/JSON values that contain out-of-range numbers"],"exampleFix":"// before\nawait SceneLoader.ImportAnimationsAsync(url, '', scene, false, 4); // invalid mode\n// after\nawait SceneLoader.ImportAnimationsAsync(url, '', scene, false, SceneLoaderAnimationGroupLoadingMode.Sync);","handlingStrategy":"validation","validationCode":"const VALID_MODES = [SceneLoaderAnimationGroupLoadingMode.Sync, SceneLoaderAnimationGroupLoadingMode.SyncAlways, SceneLoaderAnimationGroupLoadingMode.NoSync];\nif (!VALID_MODES.includes(mode)) mode = SceneLoaderAnimationGroupLoadingMode.Sync;","typeGuard":"const isValidMode = (m: number): m is SceneLoaderAnimationGroupLoadingMode =>\n  Object.values(SceneLoaderAnimationGroupLoadingMode).includes(m as SceneLoaderAnimationGroupLoadingMode);","tryCatchPattern":"try {\n  await SceneLoader.ImportAnimationsAsync(url, '', scene, overwrite, mode);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unknown animation group loading mode')) {\n    console.error('Bad animationGroupLoadingMode, falling back to Sync');\n  } else throw e;\n}","preventionTips":["Always use enum members, never raw numbers from config","Validate enum-typed values deserialized from JSON","Add a unit test for options parsing that asserts valid enum values"],"tags":["babylonjs","invalid-enum-value","animations","loader"],"backgroundTag":"invalid-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}