stride3d/stride · error · InvalidOperationException
cannot be .
Error message
{nameof(sceneId)} cannot be {nameof(Guid.Empty)}. What it means
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.
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.
Example fix
// before sceneEditorGame.AddScene(Guid.Empty, parentId); // after sceneEditorGame.AddScene(Guid.NewGuid(), parentId);
Defensive patterns
Strategy: validation
Validate before calling
if (sceneId == Guid.Empty) throw new ArgumentException("sceneId must be a valid Guid", nameof(sceneId)); Type guard
bool IsValidSceneId(Guid id) => id != Guid.Empty;
Try / catch
try { game.AddScene(sceneId, parentId); } catch (InvalidOperationException ex) when (ex.Message.Contains("Guid.Empty")) { sceneId = Guid.NewGuid(); game.AddScene(sceneId, parentId); } Prevention
- Generate ids with Guid.NewGuid() at creation time
- Never pass default(Guid) to scene APIs
- Validate ids when deserializing scene data
When it happens
Trigger: Calling AddScene(Guid.Empty, parentId), typically when a scene id was never assigned (default(Guid) passed by mistake).
Common situations: Generating scenes in a loop with an uninitialized Guid variable; deserializing scene data where ids were missing and defaulted to Guid.Empty.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- The given does not correspond to any existing part.
- The given does not correspond to any existing part.
- A scene matching the given
- Scenes with child scenes cannot be removed.
- Scenes with entities cannot be removed.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/43f1c46e1ad2ab40.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/Game/SceneEditorGame.cs:39
private readonly Dictionary<Guid, Scene> scenes = new Dictionary<Guid, Scene>();
public SceneEditorGame(TaskCompletionSource<bool> gameContentLoadedTaskSource, IEffectCompiler effectCompiler, string effectLogPath)
: base(gameContentLoadedTaskSource, effectCompiler, effectLogPath)
{
}
public event Action<Scene> SceneAdded;
public event Action<Scene> SceneRemoved;
/// <summary>
/// Adds a new scene with the provided <paramref name="sceneId"/>.
/// </summary>
/// <param name="sceneId">The identifier of the scene to add.</param>
/// <param name="parentId">The identifier of an existing parent scene, or <see cref="Guid.Empty"/>.</param>
public void AddScene(Guid sceneId, Guid parentId)
{
if (sceneId == Guid.Empty) throw new InvalidOperationException($"{nameof(sceneId)} cannot be {nameof(Guid.Empty)}.");
if (scenes.ContainsKey(sceneId)) throw new InvalidOperationException($"A scene matching the given {sceneId}, already exists.");
EnsureContentScene();
var scene = new Scene { Id = sceneId };
var parent = parentId != Guid.Empty ? GetScene(parentId) : ContentScene;
AddSceneToParent(scene, parent);
scenes.Add(sceneId, scene);
SceneAdded?.Invoke(scene);
}
/// <summary>
/// Moves an existing scene identified by <paramref name="sceneId"/> under the parent scene identified by <paramref name="parentId"/>.
/// </summary>
/// <param name="sceneId">The identifier of the scene to move.</param>
/// <param name="parentId">The identifier of an existing parent scene, or <see cref="Guid.Empty"/>.</param>
public void MoveScene(Guid sceneId, Guid parentId)
{View on GitHub (pinned to 96fad776d2)