{"record":{"id":"f80e04331a87929d","repo":"BabylonJS/Babylon.js","slug":"overridemanager-expected-an-array-of-override-ent","errorCode":null,"errorMessage":"OverrideManager: Expected an array of override entries.","messagePattern":"OverrideManager: Expected an array of override entries\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/sharedUiComponents/src/projects/overrideManager.ts","lineNumber":405,"sourceCode":"/**\r\n * Serializes all overrides to a JSON-compatible array.\r\n * The on-disk shape is identical to the in-memory `IOverrideEntry`.\r\n * @param scene - The scene whose overrides to serialize.\r\n * @returns An array of override entries (shallow copies).\r\n */\r\nexport function SerializeOverrides(scene: Scene): IOverrideEntry[] {\r\n    const internal = GetOverrideInternals(GetOverrideManager(scene));\r\n    return internal.overrides.map((o) => ({ ...o }));\r\n}\r\n\r\n/**\r\n * Loads overrides from a serialized array and applies them.\r\n * @param scene - The scene whose override registry to populate.\r\n * @param data - Array of override entries.\r\n */\r\nexport function DeserializeAndApplyOverrides(scene: Scene, data: IOverrideEntry[]): void {\r\n    if (!Array.isArray(data)) {\r\n        throw new Error(\"OverrideManager: Expected an array of override entries.\");\r\n    }\r\n\r\n    for (const entry of SortNameOverridesFirst(data)) {\r\n        if (!entry.targetType || entry.targetName === undefined || typeof entry.targetIndex !== \"number\" || !entry.propertyPath || entry.value === undefined) {\r\n            Logger.Warn(\"OverrideManager: Skipping invalid override entry.\");\r\n            continue;\r\n        }\r\n        AddOverride(scene, entry);\r\n    }\r\n}\r\n\r\n// ── Lifecycle ──\r\n\r\n/**\r\n * Disposes the manager, clearing all overrides and detaching it from its scene.\r\n * Safe to call multiple times; subsequent calls are no-ops. Automatically invoked when the\r\n * owning scene is disposed.\r\n * @param manager - The override manager state.\r","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/sharedUiComponents/src/projects/overrideManager.ts#L387-L423","documentation":"DeserializeAndApplyOverrides validates that the deserialized override payload is an array of IOverrideEntry before applying it to the scene's override registry. A non-array (null, object, string) means the project file's override section is corrupt or in an unexpected schema, so the function fails fast instead of iterating garbage.","triggerScenarios":"Calling DeserializeAndApplyOverrides(scene, data) where data is null, undefined, a plain object, or a string — typically because project JSON stored overrides under a different shape or a stale/other version of the schema.","commonSituations":"Loading a project file written by an older/newer version where overrides was an object map instead of an array; hand-edited JSON that wrapped the array in another key; failed fetch returning an error object passed straight to the deserializer.","solutions":["Fix the project file so overrides is an array of entries (version 2 schema).","Validate Array.isArray(parsed.overrides) after JSON.parse before calling the function.","If migrating from an older format, transform the old structure to the entry array first.","Check that the correct project file/version is being loaded (doc.version must be 2)."],"exampleFix":"// before\nconst data = JSON.parse(raw).overrides ?? {}; // object, not array\nDeserializeAndApplyOverrides(scene, data); // throws\n// after\nconst data = JSON.parse(raw).overrides;\nif (Array.isArray(data)) DeserializeAndApplyOverrides(scene, data);","handlingStrategy":"type-guard","validationCode":"function isOverrideEntryArray(v) {\n  return Array.isArray(v) && v.every((e) => e && typeof e === \"object\");\n}\nconst data = parsed.overrides;\nif (isOverrideEntryArray(data)) DeserializeAndApplyOverrides(scene, data);","typeGuard":"function isOverrideEntryArray(v: unknown): v is IOverrideEntry[] {\n  return Array.isArray(v) && v.every((e) => e !== null && typeof e === \"object\");\n}","tryCatchPattern":"// try {\n//   DeserializeAndApplyOverrides(scene, data);\n// } catch (e) {\n//   if (String(e.message).includes(\"Expected an array of override entries\")) {\n//     Logger.Warn(\"Project overrides missing/corrupt; skipping.\");\n//     return;\n//   }\n//   throw e;\n// }","preventionTips":["Validate parsed.overrides is an array before applying.","Keep project files on the current schema version and migrate old formats.","Never pass fetch/error objects straight into deserializers."],"tags":["validation","deserialization","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}