stride3d/stride · error · ArgumentException
This tool requires a build path.
Error message
This tool requires a build path.
What it means
ObjectReference.SetTarget validates that the content retrieved from the candidate target node is an instance of this reference's declared type; if a non-null retrieved value has an unrelated type, it throws InvalidOperationException rather than pointing the reference at incompatible content. This protects consumers that Retrieve through the reference expecting the declared type.
Solutions
- Retarget the reference to a node whose content is assignable to the reference's type.
- Validate with type.IsInstanceOfType(targetNode.Retrieve()) before calling SetTarget.
- If the type legitimately changed, recreate the ObjectReference with the new type instead of retargeting.
Example fix
// before
reference.SetTarget(otherNode); // otherNode content is a different type
// after
var value = otherNode.Retrieve();
if (value == null || /* refType */ typeof(MyModel).IsInstanceOfType(value))
reference.SetTarget(otherNode); Defensive patterns
Strategy: type-guard
Validate before calling
var v = targetNode.Retrieve();
if (v != null && !typeof(MyModel).IsInstanceOfType(v))
throw new InvalidOperationException("Target node content type does not match reference type"); Type guard
bool IsValidTarget(ObjectReference rf, IObjectNode node) { var v = node.Retrieve(); return v == null || rf.Type.IsInstanceOfType(v); } Try / catch
try { reference.SetTarget(candidateNode); }
catch (InvalidOperationException ex) when (ex.Message.Contains("does not match")) { /* pick a node of the declared type or recreate the reference */ } Prevention
- Check the candidate node's content type before retargeting
- Recreate references when the target property type changes
- In reference-fixing UIs, filter candidate nodes by declared type
When it happens
Trigger: Calling SetTarget(targetNode) where targetNode.Retrieve() returns a non-null object not assignable to the reference's type — e.g. retargeting a reference to a node of a different property type, or after a refactor changed the target node's content type.
Common situations: Fixing broken object references (scene/asset editors) by pointing them at the wrong node; model refactors that changed a property's type while serialized references still expect the old type.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unexpected arguments
- Type [ ] must be assignable to Asset or be a Package
- Type [ ] must be assignable to Asset
- compilationContext should inherit from ICompilationContext
- Cannot serialize an object of type
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/52fc7b0d04d637c8.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.AssetCompiler/PackageBuilderOptions.cs:81
/// <summary>
/// This function indicate if the current builder options mean to execute a slave session
/// </summary>
/// <returns>true if the options mean to execute a slave session</returns>
public bool IsValidForSlave()
{
return !string.IsNullOrEmpty(SlavePipe) && !string.IsNullOrEmpty(BuildDirectory);
}
/// <summary>
/// Ensure every parameter is correct for a master execution. Throw an OptionException if a parameter is wrong
/// </summary>
/// <exception cref="Mono.Options.OptionException">This tool requires one input file.;filename
/// or
/// The given working directory \ + workingDir + \ does not exist.;workingdir</exception>
public void ValidateOptions()
{
if (string.IsNullOrWhiteSpace(BuildDirectory))
throw new ArgumentException("This tool requires a build path.", "build-path");
try
{
BuildDirectory = Path.GetFullPath(BuildDirectory);
}
catch (Exception)
{
throw new ArgumentException("The provided path is not a valid path name.", "build-path");
}
if (SlavePipe == null)
{
if (!string.IsNullOrWhiteSpace(PackageManifestFile))
{
if (!File.Exists(PackageManifestFile))
throw new ArgumentException("Build manifest [{0}] doesn't exist".ToFormat(PackageManifestFile), "packageManifestFile");
}
else if (string.IsNullOrWhiteSpace(PackageFile))View on GitHub (pinned to 96fad776d2)