{"record":{"id":"368ebecf2cdfa2e6","repo":"LykosAI/StabilityMatrix","slug":"invalid-or-unsupported-package-specifier-for-uv-value","errorCode":null,"errorMessage":"Invalid or unsupported package specifier for uv: {value}","messagePattern":"Invalid or unsupported package specifier for uv: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/UvPackageSpecifier.cs","lineNumber":62,"sourceCode":"        // Enhancements could be made here to support git URLs, local paths, etc. if needed.\n        var match = PackageSpecifierRegex().Match(value);\n        if (!match.Success)\n        {\n            // Check if it's a URL or path-like specifier (basic check)\n            // uv supports these directly. For simplicity, we'll treat them as a Name-only specifier for now.\n            if (\n                Uri.IsWellFormedUriString(value, UriKind.Absolute)\n                || value.Contains(Path.DirectorySeparatorChar)\n                || value.Contains(Path.AltDirectorySeparatorChar)\n            )\n            {\n                packageSpecifier = new UvPackageSpecifier { Name = value };\n                return true;\n            }\n\n            if (throwOnFailure)\n            {\n                throw new ArgumentException($\"Invalid or unsupported package specifier for uv: {value}\");\n            }\n\n            packageSpecifier = null;\n            return false;\n        }\n\n        packageSpecifier = new UvPackageSpecifier\n        {\n            Name = match.Groups[\"package_name\"].Value,\n            Constraint = match.Groups[\"version_constraint\"].Value, // Will be empty string if no constraint\n            Version = match.Groups[\"version\"].Value // Will be empty string if no version\n        };\n\n        // Ensure Constraint and Version are null if they were empty strings from regex.\n        if (string.IsNullOrEmpty(packageSpecifier.Constraint))\n            packageSpecifier.Constraint = null;\n        if (string.IsNullOrEmpty(packageSpecifier.Version))\n            packageSpecifier.Version = null;","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/UvPackageSpecifier.cs#L44-L80","documentation":"UvPackageSpecifier.TryParse only accepts name, name+version specifiers and PEP 508-style extras/constraint forms it recognizes; on throwOnFailure=true it throws ArgumentException for anything else. It guards the uv-based pip alternative against specifiers it cannot map.","triggerScenarios":"Calling the TryParse overload with throwOnFailure:true and a specifier such as a local path, URL, VCS link (git+https://...), or an unsupported syntax the uv specifier parser doesn't model.","commonSituations":"Installing directly from git URLs or local wheel paths through the uv path; typo'd requirement strings; requirements-style lines with environment markers the parser rejects.","solutions":["Use a standard PyPI specifier: name, name==version, name[extra]>=version.","Install from URLs/paths/VCS via the regular pip pipeline instead of the uv path.","Call the non-throwing TryParse overload to validate user input first.","Check for typos (double '==', stray semicolons, markers) in the specifier."],"exampleFix":"// before\nUvPackageSpecifier.TryParse(\"git+https://github.com/x/y.git\", out var spec, throwOnFailure: true);\n// after\nif (!UvPackageSpecifier.TryParse(\"torch>=2.1\", out var spec, throwOnFailure: true)) { /* handled */ }","handlingStrategy":"validation","validationCode":"bool IsSupportedSpecifier(string s) =>\n    !s.StartsWith(\"git+\") && !Uri.IsWellFormedUriString(s, UriKind.Absolute) &&\n    !s.Contains(';') && System.Text.RegularExpressions.Regex.IsMatch(s, \"^[A-Za-z0-9._-]+(\\[.*\\])?(.*)?$\");","typeGuard":"static bool IsPlainRequirement(string s) {\n    var name = System.Text.RegularExpressions.Regex.Match(s, \"^[A-Za-z0-9._-]+\");\n    return name.Success && !s.StartsWith(\"git+\") && !File.Exists(s) && !Uri.IsWellFormedUriString(s, UriKind.Absolute);\n}","tryCatchPattern":"try { ok = UvPackageSpecifier.TryParse(spec, out var p, throwOnFailure: true); }\ncatch (ArgumentException ex) { Logger.Warn(ex, \"unsupported uv specifier {Spec}\", spec); ok = false; }","preventionTips":["Validate specifiers with the non-throwing TryParse before the throwing call","Route git+/URL/path installs through pip, not uv","Keep specifier strings in canonical 'name[extras]op version' form"],"tags":["python","uv","package-specifier","argument-exception"],"backgroundTag":"invalid-argument-value","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}