{"record":{"id":"a7a2e07c173d946e","repo":"stride3d/stride","slug":"unexpected-null-typeof-t-fullname-while-cloning","errorCode":null,"errorMessage":"Unexpected null {typeof(T).FullName} while cloning","messagePattern":"Unexpected null (.+?) while cloning","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/AssetCloner.cs","lineNumber":358,"sourceCode":"        {\n            var invariantObjectList = stream.Context.Get(InvariantObjectListProperty)!;\n            if (mode == ArchiveMode.Serialize)\n            {\n                stream.Write(invariantObjectList.Count);\n                invariantObjectList.Add(obj);\n            }\n            else\n            {\n                var index = stream.Read<int>();\n\n                if (index >= invariantObjectList.Count)\n                {\n                    throw new InvalidOperationException($\"The type [{typeof(T).FullName}] cannot be only be used for clone serialization\");\n                }\n\n                if (invariantObjectList[index] is not T invariant)\n                {\n                    throw new InvalidOperationException($\"Unexpected null {typeof(T).FullName} while cloning\");\n                }\n\n                // Create a new object to avoid exception in case its identity is important\n                obj = (T)Activator.CreateInstance(typeof(T), invariant.TypeName, invariant.AssemblyName, invariant.Error, invariant.ParsingEvents)!;\n            }\n        }\n\n        public override void Serialize(ref T obj, ArchiveMode mode, SerializationStream stream)\n        {\n            // Process with parent serializer first\n            object parentObj = obj;\n            parentSerializer?.Serialize(ref parentObj, mode, stream);\n            obj = (T)parentObj;\n        }\n    }\n}\n","sourceCodeStart":340,"sourceCodeEnd":375,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/AssetCloner.cs#L340-L375","documentation":"Internal clone-serialization error in AssetCloner.PreSerialize (deserialization side): the object resolved from the invariant-object list for the read index is null, i.e. the clone stream referenced an invariant object slot that was never populated during serialization. Points to a mismatch between serialize and deserialize passes of the cloner.","triggerScenarios":"Thrown at sources/assets/Stride.Core.Assets/AssetCloner.cs:358 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the object graph doesn't change between cloning passes (no concurrent mutation)","Ensure a single AssetCloner configuration handles both sides of the clone","Report as an engine bug if it reproduces deterministically"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}