{"record":{"id":"f473bbb5d5dfd8ee","repo":"stride3d/stride","slug":"invalid-geometricprimitive-0-expecting-a-non-null-type","errorCode":null,"errorMessage":"Invalid GeometricPrimitive [{0}]. Expecting a non-null Type","messagePattern":"Invalid GeometricPrimitive \\[(.+?)\\]\\. Expecting a non-null Type","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/ProceduralModels/ProceduralModelDescriptor.cs","lineNumber":59,"sourceCode":"        [DataMember(10)]\n        [NotNull]\n        [Display(\"Type\", Expand = ExpandRule.Always)]\n        public IProceduralModel Type { get; set; }\n\n        public Model GenerateModel(IServiceRegistry services)\n        {\n            var model = new Model();\n            GenerateModel(services, model);\n            return model;\n        }\n\n        public void GenerateModel(IServiceRegistry services, Model model)\n        {\n            if (model == null) throw new ArgumentNullException(nameof(model));\n\n            if (Type == null)\n            {\n                throw new InvalidOperationException(\"Invalid GeometricPrimitive [{0}]. Expecting a non-null Type\");\n            }\n\n            Type.Generate(services, model);\n        }\n    }\n}\n","sourceCodeStart":41,"sourceCodeEnd":66,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/ProceduralModels/ProceduralModelDescriptor.cs#L41-L66","documentation":"ProceduralModelDescriptor.GenerateModel requires its Type property (the IProceduralModel describing the primitive) to be set before generating into the target Model. A null Type throws InvalidOperationException; the descriptor has no primitive to build.","triggerScenarios":"Calling GenerateModel on a ProceduralModelDescriptor whose Type was never assigned (e.g. a descriptor created in code without setting Type), or a descriptor whose Type field was reset/deserialized as null.","commonSituations":"Building procedural models programmatically and forgetting to set descriptor.Type; assets saved by older versions where Type was not serialized; scene/model assets with partially configured primitive descriptors.","solutions":["Set descriptor.Type to a PrimitiveProceduralModelBase instance (e.g. new SphereProceduralModel()) before calling GenerateModel","Fix the asset serialization so Type is saved/loaded (re-save the descriptor asset)","Guard the call site by checking descriptor.Type != null before invoking GenerateModel"],"exampleFix":"// before\nvar descriptor = new ProceduralModelDescriptor();\ndescriptor.GenerateModel(services, model); // throws: Type is null\n// after\nvar descriptor = new ProceduralModelDescriptor { Type = new SphereProceduralModel() };\ndescriptor.GenerateModel(services, model);","handlingStrategy":"validation","validationCode":"if (descriptor?.Type == null)\n    throw new InvalidOperationException(\"ProceduralModelDescriptor.Type must be set before GenerateModel\");\ndescriptor.GenerateModel(services, model);","typeGuard":"static bool IsReady(ProceduralModelDescriptor d) => d?.Type != null;","tryCatchPattern":"try { descriptor.GenerateModel(services, model); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"non-null Type\")) {\n    descriptor.Type = new CubeProceduralModel(); // sensible default\n    descriptor.GenerateModel(services, model);\n}","preventionTips":["Always initialize descriptor.Type in object initializers","Re-save assets after schema changes so Type is serialized","Unit-test procedural descriptor creation paths for null Type"],"tags":["rendering","procedural-models","null-value"],"backgroundTag":"null-argument","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"}