stride3d/stride · error · ArgumentException
Url must be valid, assign null instead
Error message
Url must be valid, assign null instead
What it means
BepuSimulation.AssociatedScene setter throws ArgumentException when assigned a UrlReference<Scene> that IsEmpty (default-constructed, pointing to no scene). Because a null assignment legitimately means 'no associated scene', the library forbids an empty URL value and instructs you to assign null instead.
Solutions
- Assign null instead of an empty UrlReference<Scene> when you mean 'no scene'
- Check value.IsEmpty in your own code before assigning and substitute null
- Fill in the scene reference in the editor/Game Studio property so the URL is non-empty
- If the value comes from deserialization, validate the source field for null/empty before constructing UrlReference<Scene>
Example fix
// before
simulation.AssociatedScene = new UrlReference<Scene>("", null); // IsEmpty == true
// after
simulation.AssociatedScene = string.IsNullOrEmpty(rawUrl) ? (UrlReference<Scene>?)null : new UrlReference<Scene>(rawUrl); Defensive patterns
Strategy: type-guard
Validate before calling
if (sceneUrl is UrlReference<Scene> u && u.IsEmpty)
sceneUrl = null; // normalize empty URLs to null before assigning Type guard
bool IsValidSceneRef(UrlReference<Scene>? url) => url is null || !url.Value.IsEmpty;
Try / catch
try
{
simulation.AssociatedScene = sceneUrl;
}
catch (ArgumentException ex) when (ex.Message.Contains("Url must be valid"))
{
Logger.Warn("Empty scene URL assigned; defaulting to null");
simulation.AssociatedScene = null;
} Prevention
- Treat 'no scene' as null, never as a default-constructed UrlReference<Scene>
- Validate scene reference fields after deserialization of entities
- Fill scene pickers in Game Studio before attaching BepuSimulation components
- Write a shared normalizer that maps empty URLs to null across your codebase
When it happens
Trigger: Setting simulation.AssociatedScene = new UrlReference<Scene>() (default struct, no URL) or deserializing an entity whose scene URL field was left empty and then assigning it to the property.
Common situations: Wiring a BepuSimulation component in an editor/serializer where the scene picker was never filled in; constructing UrlReference<Scene> from an empty string; copying a component from another entity without the scene reference surviving serialization.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Mesh seems to have no volume; triangle rasterization…
- 's must be finite
- 's must be normalized
- 's must be finite and greater than zero
- Invalid Width/Height/Depth/ArraySize for Image 1D
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/de31b4ae7aa31acd.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/BepuSimulation.cs:89
/// <summary>
/// The scene associated with this simulation.
/// </summary>
/// <remarks>
/// When this is set, entities spawning inside this scene will be automatically associated with
/// this simulation as long as their <see cref="CollidableComponent.SimulationSelector"/> is set to <see cref="SceneBasedSimulationSelector"/>.
/// See <see cref="SceneBasedSimulationSelector"/> for more info.
/// </remarks>
public UrlReference<Scene>? AssociatedScene
{
get
{
return _associatedScene;
}
set
{
if (value?.IsEmpty == true)
throw new ArgumentException("Url must be valid, assign null instead");
_associatedScene = value;
}
}
/// <summary>
/// The number of threads the simulation may use.
/// </summary>
/// <remarks>
/// <see cref="Dispatcher.MaxDegreeOfParallelism"/> is the upper bound, -1 will default to that value.
/// A value greater than <see cref="Dispatcher.MaxDegreeOfParallelism"/> will further split the work, potentially improving throughput depending on the context and simulation.
/// </remarks>
[Display(-1, "Thread Count")]
public int ThreadCount
{
get;
set
{View on GitHub (pinned to 96fad776d2)