stride3d/stride · error · ArgumentException

The target version is lower or equal to the start version.

Error message

The target version is lower or equal to the start version.

What it means

AssetUpgraderAttribute's constructor parses startMinVersion and targetVersion into PackageVersion and enforces that the upgrade range moves forward: TargetVersion must be strictly greater than StartVersion. The library uses these ranges to build an ordered chain of asset upgraders, so a non-advancing (or backwards) range would be meaningless and break the upgrade graph. It throws ArgumentException naming targetVersion when TargetVersion <= StartVersion.

Solutions

  1. Ensure targetVersion is strictly greater than startMinVersion in the attribute arguments.
  2. Check for swapped argument order: the signature is (startMinVersion, targetVersion, upgraderType).
  3. If the upgrader is a no-op for the same version range, remove it entirely instead of registering it.
  4. Verify version constants/strings were updated when porting the upgrader to a new package version.

Example fix

// before
[AssetUpgrader(AssetUpgraderVersions.Start, "4.1.0.0", typeof(MyAssetUpgrader))] // Start == 4.1.0.0
// after
[AssetUpgrader(AssetUpgraderVersions.Start, "4.2.0.0", typeof(MyAssetUpgrader))] // target > start
Defensive patterns

Strategy: validation

Validate before calling

var start = PackageVersion.Parse(startMinVersion);
var target = PackageVersion.Parse(targetVersion);
if (target <= start)
    throw new ArgumentException(nameof(targetVersion), $"targetVersion ({target}) must be greater than startMinVersion ({start})");

Type guard

static bool IsForwardUpgrade(PackageVersion start, PackageVersion target) => target > start;

Try / catch

try
{
    var attr = new AssetUpgraderAttribute(start, target, upgraderType);
}
catch (ArgumentException ex) when (ex.ParamName == nameof(targetVersion))
{
    // log: start/target versions are not strictly increasing
}

Prevention

When it happens

Trigger: Constructing AssetUpgraderAttribute (or the derived attribute used on asset upgrader classes) with a targetVersion string that parses equal to or lower than startMinVersion, e.g. [AssetUpgrader("4.1.0.0", "4.0.0.0", typeof(MyUpgrader))] or equal versions [AssetUpgrader("4.1.0.0", "4.1.0.0", ...)].

Common situations: Copy-pasting an existing upgrader attribute and forgetting to bump targetVersion after bumping startVersion; swapping the two version arguments by mistake; authoring a no-op upgrader with identical start/target versions; refactoring version constants so they resolve to the same value.

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


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/ab138979fceaf387. Report an issue: GitHub.

Appendix: source

Thrown at sources/assets/Stride.Core.Assets/AssetUpgraderAttribute.cs:27

public class AssetUpgraderAttribute : Attribute
{
    /// <summary>
    /// Initializes a new instance of the <see cref="AssetUpgraderAttribute"/> with a range of supported initial version numbers.
    /// </summary>
    /// <param name="name">The dependency name.</param>
    /// <param name="startMinVersion">The minimal initial version number this upgrader can work on.</param>
    /// <param name="targetVersion">The target version number of this upgrader.</param>
    /// <param name="assetUpgraderType">The type of upgrader to instantiate to upgrade the asset.</param>
    public AssetUpgraderAttribute(string name, string startMinVersion, string targetVersion, Type assetUpgraderType)
    {
        Name = name;
        StartVersion = PackageVersion.Parse(startMinVersion);
        TargetVersion = PackageVersion.Parse(targetVersion);

        if (!typeof(IAssetUpgrader).IsAssignableFrom(assetUpgraderType))
            throw new ArgumentException("The assetUpgraderType must implement IAssetUpgrader interface", nameof(assetUpgraderType));
        if (TargetVersion <= StartVersion)
            throw new ArgumentException("The target version is lower or equal to the start version.", nameof(targetVersion));
        AssetUpgraderType = assetUpgraderType;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="AssetUpgraderAttribute"/> with a single supported initial version number.
    /// </summary>
    /// <param name="name">The dependency name.</param>
    /// <param name="startVersion">The initial version number this upgrader can work on.</param>
    /// <param name="targetVersion">The target version number of this upgrader.</param>
    /// <param name="assetUpgraderType">The type of upgrader to instantiate to upgrade the asset.</param>
    public AssetUpgraderAttribute(string name, int startVersion, int targetVersion, Type assetUpgraderType)
        : this(name, "0.0." + startVersion, "0.0." + targetVersion, assetUpgraderType)
    {
    }

    /// <summary>
    /// Gets or sets the dependency name.
    /// </summary>

View on GitHub (pinned to 96fad776d2)