{"record":{"id":"43f1c46e1ad2ab40","repo":"stride3d/stride","slug":"nameof-sceneid-cannot-be-nameof-guid-empty","errorCode":null,"errorMessage":"{nameof(sceneId)} cannot be {nameof(Guid.Empty)}.","messagePattern":"(.+?) cannot be (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/Game/SceneEditorGame.cs","lineNumber":39,"sourceCode":"        private readonly Dictionary<Guid, Scene> scenes = new Dictionary<Guid, Scene>();\n\n        public SceneEditorGame(TaskCompletionSource<bool> gameContentLoadedTaskSource, IEffectCompiler effectCompiler, string effectLogPath)\n            : base(gameContentLoadedTaskSource, effectCompiler, effectLogPath)\n        {\n\n        }\n\n        public event Action<Scene> SceneAdded;\n        public event Action<Scene> SceneRemoved;\n\n        /// <summary>\n        /// Adds a new scene with the provided <paramref name=\"sceneId\"/>.\n        /// </summary>\n        /// <param name=\"sceneId\">The identifier of the scene to add.</param>\n        /// <param name=\"parentId\">The identifier of an existing parent scene, or <see cref=\"Guid.Empty\"/>.</param>\n        public void AddScene(Guid sceneId, Guid parentId)\n        {\n            if (sceneId == Guid.Empty) throw new InvalidOperationException($\"{nameof(sceneId)} cannot be {nameof(Guid.Empty)}.\");\n            if (scenes.ContainsKey(sceneId)) throw new InvalidOperationException($\"A scene matching the given {sceneId}, already exists.\");\n\n            EnsureContentScene();\n\n            var scene = new Scene { Id = sceneId };\n            var parent = parentId != Guid.Empty ? GetScene(parentId) : ContentScene;\n            AddSceneToParent(scene, parent);\n            scenes.Add(sceneId, scene);\n            SceneAdded?.Invoke(scene);\n        }\n\n        /// <summary>\n        /// Moves an existing scene identified by <paramref name=\"sceneId\"/> under the parent scene identified by <paramref name=\"parentId\"/>.\n        /// </summary>\n        /// <param name=\"sceneId\">The identifier of the scene to move.</param>\n        /// <param name=\"parentId\">The identifier of an existing parent scene, or <see cref=\"Guid.Empty\"/>.</param>\n        public void MoveScene(Guid sceneId, Guid parentId)\n        {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/Game/SceneEditorGame.cs#L21-L57","documentation":"SceneEditorGame.AddScene rejects a sceneId equal to Guid.Empty with an InvalidOperationException. A scene must have a real identifier because it is keyed in the internal scenes dictionary and referenced by parent/child links.","triggerScenarios":"Calling AddScene(Guid.Empty, parentId), typically when a scene id was never assigned (default(Guid) passed by mistake).","commonSituations":"Generating scenes in a loop with an uninitialized Guid variable; deserializing scene data where ids were missing and defaulted to Guid.Empty.","solutions":["Generate a valid id with Guid.NewGuid() before calling AddScene.","Load the actual scene identifier from the asset instead of passing a default Guid.","Skip or log scenes with empty ids instead of adding them."],"exampleFix":"// before\nsceneEditorGame.AddScene(Guid.Empty, parentId);\n// after\nsceneEditorGame.AddScene(Guid.NewGuid(), parentId);","handlingStrategy":"validation","validationCode":"if (sceneId == Guid.Empty) throw new ArgumentException(\"sceneId must be a valid Guid\", nameof(sceneId));","typeGuard":"bool IsValidSceneId(Guid id) => id != Guid.Empty;","tryCatchPattern":"try { game.AddScene(sceneId, parentId); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Guid.Empty\")) { sceneId = Guid.NewGuid(); game.AddScene(sceneId, parentId); }","preventionTips":["Generate ids with Guid.NewGuid() at creation time","Never pass default(Guid) to scene APIs","Validate ids when deserializing scene data"],"tags":["stride-editor","scene","guid","invalid-argument-value"],"backgroundTag":"empty-required-field","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}