{"record":{"id":"13487cb7167b2918","repo":"stride3d/stride","slug":"invalid-version-format-unable-to-decode-0","errorCode":null,"errorMessage":"Invalid version format. Unable to decode [{0}]","messagePattern":"Invalid version format\\. Unable to decode \\[(.+?)\\]","errorType":"validation","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Serializers/PackageVersionSerializer.cs","lineNumber":25,"sourceCode":"\nnamespace Stride.Core.Assets.Serializers;\n\n/// <summary>\n/// A Yaml serializer for <see cref=\"PackageVersion\"/>\n/// </summary>\n[YamlSerializerFactory(YamlAssetProfile.Name)]\ninternal class PackageVersionSerializer : AssetScalarSerializerBase\n{\n    public override bool CanVisit(Type type)\n    {\n        return typeof(PackageVersion).IsAssignableFrom(type);\n    }\n\n    public override object ConvertFrom(ref ObjectContext context, Scalar fromScalar)\n    {\n        if (!PackageVersion.TryParse(fromScalar.Value, out var packageVersion))\n        {\n            throw new YamlException(fromScalar.Start, fromScalar.End, \"Invalid version format. Unable to decode [{0}]\".ToFormat(fromScalar.Value));\n        }\n        return packageVersion;\n    }\n\n    public override string ConvertTo(ref ObjectContext objectContext)\n    {\n        return objectContext.Instance.ToString()!;\n    }\n}\n","sourceCodeStart":7,"sourceCodeEnd":35,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Serializers/PackageVersionSerializer.cs#L7-L35","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nVersion: v4.1.0-beta\n// after\nVersion: 4.1.0","handlingStrategy":"validation","validationCode":"if (PackageVersion.TryParse(versionText, out var v)) { use(v); } else { fixOrSkip(versionText); }","typeGuard":"bool IsValidPackageVersion(string? s) => s != null && PackageVersion.TryParse(s, out _);","tryCatchPattern":"try { LoadPackage(file); } catch (YamlException ex) when (ex.Message.Contains(\"Invalid version format\")) { log.Error($\"Bad version in {file}: {ex.Message}\"); throw; }","preventionTips":["Use strict major.minor.build numeric versions in .pkg files","Never include NuGet-style prefixes or suffixes","Validate versions in CI before packaging"],"tags":["yaml","versioning","packages","parsing"],"backgroundTag":"invalid-date-format","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}