{"record":{"id":"9a991fb69d403b2f","repo":"stride3d/stride","slug":"invalid-version-format-version","errorCode":null,"errorMessage":"Invalid version format [{version}]","messagePattern":"Invalid version format \\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Design/PackageVersion.cs","lineNumber":169,"sourceCode":"            string[] b = [\"0\", \"0\", \"0\", \"0\"];\n            Array.Copy(a, 0, b, 0, a.Length);\n            return b;\n        }\n    }\n\n    /// <summary>\n    /// Parses a version string using loose semantic versioning rules that allows 2-4 version components followed by an optional special version.\n    /// </summary>\n    public static PackageVersion Parse(string version)\n    {\n        if (string.IsNullOrEmpty(version))\n        {\n            throw new ArgumentNullException(nameof(version), \"cannot be null or empty\");\n        }\n\n        if (!TryParse(version, out var semVer))\n        {\n            throw new ArgumentException($\"Invalid version format [{version}]\", nameof(version));\n        }\n        return semVer;\n    }\n\n    /// <summary>\n    /// Parses a version string using loose semantic versioning rules that allows 2-4 version components followed by an optional special version.\n    /// </summary>\n    public static bool TryParse(string version, [MaybeNullWhen(false)] out PackageVersion value)\n    {\n        return TryParseInternal(version, SemanticVersionRegex, out value);\n    }\n\n    /// <summary>\n    /// Parses a version string using strict semantic versioning rules that allows exactly 3 components and an optional special version.\n    /// </summary>\n    public static bool TryParseStrict(string version, [MaybeNullWhen(false)] out PackageVersion value)\n    {\n        return TryParseInternal(version, StrictSemanticVersionRegex, out value);","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Design/PackageVersion.cs#L151-L187","documentation":"PackageVersion.Parse strictly validates the version string via TryParse (loose semver: 2-4 numeric components plus optional special version). If the string does not match, an ArgumentException with the offending input is thrown, naming the version parameter.","triggerScenarios":"Calling Parse with strings like \"1\", \"abc\", \"1.2.3.4.5\", \"1..2\", or a version with invalid special suffix that TryParse rejects.","commonSituations":"Reading version values from package manifests, config files, or CLI arguments where the format was hand-edited; migrating between versioning schemes (e.g. full SemVer with build metadata not accepted); trimming/whitespace or locale-formatted numbers.","solutions":["Validate the string against the expected 2-4 component numeric format before calling Parse.","Use PackageVersion.TryParse and handle the false case instead of Parse.","Normalize the input (trim, strip build metadata like '+build') before parsing.","Log the raw value; fix the source config/manifest to a valid format like \"1.2.0\"."],"exampleFix":"// before\nvar v = PackageVersion.Parse(userInput); // throws on \"v1.2\"\n// after\nif (PackageVersion.TryParse(userInput.TrimStart('v'), out var v)) { /* use v */ } else { /* handle invalid */ }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(versionString) || !PackageVersion.TryParse(versionString, out _)) throw new FormatException($\"Invalid version: {versionString}\");\nvar v = PackageVersion.Parse(versionString);","typeGuard":"bool IsValidVersion(string? s) => !string.IsNullOrWhiteSpace(s) && PackageVersion.TryParse(s, out _);","tryCatchPattern":"try { var v = PackageVersion.Parse(input); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid version format\")) { /* surface config error to user */ }","preventionTips":["Prefer TryParse for untrusted input","Trim and strip 'v' prefixes / build metadata before parsing","Validate version fields in configs/manifests at load time"],"tags":["csharp","versioning","parsing","validation"],"backgroundTag":"invalid-argument-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"}