{"record":{"id":"ea31b9cc4d3dd21e","repo":"Devolutions/UniGetUI","slug":"apt-does-not-support-installing-arbitrary-versions","errorCode":null,"errorMessage":"APT does not support installing arbitrary versions","messagePattern":"APT does not support installing arbitrary versions","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/UniGetUI.PackageEngine.Managers.Apt/Helpers/AptPkgDetailsHelper.cs","lineNumber":161,"sourceCode":"        // Must drain all stdout before WaitForExit — packages with many files\n        // will fill the pipe buffer and deadlock if we stop reading early.\n        string? result = null;\n        string? line;\n        while ((line = p.StandardOutput.ReadLine()) is not null)\n        {\n            if (result is not null) continue;\n            var path = line.Trim();\n            if (Directory.Exists(path))\n                result = path;\n        }\n\n        p.StandardError.ReadToEnd();\n        p.WaitForExit();\n        return result;\n    }\n\n    protected override IReadOnlyList<string> GetInstallableVersions_UnSafe(IPackage package)\n        => throw new InvalidOperationException(\"APT does not support installing arbitrary versions\");\n}\n","sourceCodeStart":143,"sourceCodeEnd":163,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.PackageEngine.Managers.Apt/Helpers/AptPkgDetailsHelper.cs#L143-L163","documentation":"Apt's GetInstallableVersions_UnSafe unconditionally throws InvalidOperationException because apt only installs the candidate version exposed by the configured repositories and cannot pin arbitrary versions. The base class calls this when the UI/API asks for the list of installable versions for a package.","triggerScenarios":"Any code path that requests installable versions for an Apt package: the package details page version picker, or an operation that resolves available versions before install.","commonSituations":"UI tries to populate a 'choose version' dropdown for an apt package; automation requests version metadata expecting a list.","solutions":["Gate UI/automation on the manager's Capabilities: only request versions when Supports ArbitraryVersions (or equivalent capability) is true.","For apt, install without specifying a version (use the repository candidate) and disable the version-picker control.","Catch InvalidOperationException around version-fetching and fall back to the single candidate version from package details."],"exampleFix":"// before\nvar versions = await pkg.GetInstallableVersionsAsync(); // throws for apt\n// after\nif (pkg.Manager.Capabilities.SupportsArbitraryVersions)\n    versions = await pkg.GetInstallableVersionsAsync();\nelse\n    versions = [pkg.Version];","handlingStrategy":"validation","validationCode":"// Caller: only request versions when the manager supports it.\nif (package.Manager.Capabilities.SupportsArbitraryVersions)\n    versions = package.GetInstallableVersionsAsync();\nelse\n    versions = new[] { package.Version };","typeGuard":"// Type guard on capability.\nstatic bool CanListVersions(IPackage pkg) =>\n    pkg.Manager.Capabilities.SupportsArbitraryVersions;","tryCatchPattern":null,"preventionTips":["Gate version-picker UI on the manager capability flag.","For apt, install without a version pin.","Centralize the capability check so no caller reaches the throw."],"tags":["apt","capability-not-supported","versions","package-manager"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}