stride3d/stride · error · YamlException
Invalid version format. Unable to decode
Error message
Invalid version format. Unable to decode [{0}] What it means
PackageVersionSerializer.ConvertFrom throws this when a YAML scalar expected to be a PackageVersion cannot be parsed by PackageVersion.TryParse. Stride package versions follow a strict format (e.g. major.minor[.build[.revision]]); invalid text aborts package deserialization.
Solutions
- Rewrite the version at the reported line in PackageVersion format (e.g. '4.1.0')
- Remove invalid suffixes or prefixes (v, -beta, *) from the version string
- Check the number of numeric components matches what PackageVersion.TryParse accepts
- Verify against other working package files in the same project
Example fix
// before Version: v4.1.0-beta // after Version: 4.1.0
Defensive patterns
Strategy: validation
Validate before calling
if (PackageVersion.TryParse(versionText, out var v)) { use(v); } else { fixOrSkip(versionText); } Type guard
bool IsValidPackageVersion(string? s) => s != null && PackageVersion.TryParse(s, out _);
Try / catch
try { LoadPackage(file); } catch (YamlException ex) when (ex.Message.Contains("Invalid version format")) { log.Error($"Bad version in {file}: {ex.Message}"); throw; } Prevention
- Use strict major.minor.build numeric versions in .pkg files
- Never include NuGet-style prefixes or suffixes
- Validate versions in CI before packaging
When it happens
Trigger: Deserializing a package whose Version or dependency version scalar is not a valid PackageVersion: non-numeric parts, too many components, empty string, or pre-release/NuGet suffixes unsupported by the parser.
Common situations: Hand-editing .pkg files with versions like '1.0.0-beta' or 'v1.2'; typos such as '1..2'; copying versions from other ecosystems with different formats.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid version dependency format. Unable to decode
- Unable to load the given stream
- Upgrading project [ ] to use [ ] from version [ ] to [ ] is…
- Upgrading package [ ] to use [ ] from version [ ] to [ ] is…
- Invalid version format
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/13487cb7167b2918.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Serializers/PackageVersionSerializer.cs:25
namespace Stride.Core.Assets.Serializers;
/// <summary>
/// A Yaml serializer for <see cref="PackageVersion"/>
/// </summary>
[YamlSerializerFactory(YamlAssetProfile.Name)]
internal class PackageVersionSerializer : AssetScalarSerializerBase
{
public override bool CanVisit(Type type)
{
return typeof(PackageVersion).IsAssignableFrom(type);
}
public override object ConvertFrom(ref ObjectContext context, Scalar fromScalar)
{
if (!PackageVersion.TryParse(fromScalar.Value, out var packageVersion))
{
throw new YamlException(fromScalar.Start, fromScalar.End, "Invalid version format. Unable to decode [{0}]".ToFormat(fromScalar.Value));
}
return packageVersion;
}
public override string ConvertTo(ref ObjectContext objectContext)
{
return objectContext.Instance.ToString()!;
}
}
View on GitHub (pinned to 96fad776d2)