Fix virtual package parsing to prevent invalid cache entries#171
Fix virtual package parsing to prevent invalid cache entries#171
Conversation
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
| } | ||
|
|
||
| // Check if the output is just "Reverse Provides:" with no actual package info | ||
| trimmedOutput := strings.TrimSpace(execution.CombinedOut) |
There was a problem hiding this comment.
There are other code locations where virtual packages are evaluated. Consolidate this logic and how it is reported.
There was a problem hiding this comment.
Consolidated virtual package detection by introducing isVirtualPackage helper function (commit 49b6053). This centralizes the logic for detecting "as it is purely virtual" messages and makes the code more maintainable.
| // Check if the output is just "Reverse Provides:" with no actual package info | ||
| trimmedOutput := strings.TrimSpace(execution.CombinedOut) | ||
| if trimmedOutput == "Reverse Provides:" { | ||
| return pkg, fmt.Errorf("virtual package '%s' has no concrete package providers", name) |
There was a problem hiding this comment.
Would we lose efficiency if the code automatically gets a concrete package related to it and installs that?
There was a problem hiding this comment.
The code already automatically resolves virtual packages to concrete ones when providers are available (e.g., libz-dev → zlib1g-dev), preserving efficiency. When no providers exist (e.g., python on Ubuntu 24.04), it fails with a clear error message. This prevents silent failures while maintaining efficiency for resolvable virtual packages.
|
@copilot Please continue working on this PR. |
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
| 2025/09/30 07:33:27 Encountered error resolving some or all package names, see combined std[out,err] below. | ||
| virtual package 'python' has no concrete package providers | ||
| virtual package 'python' has no concrete package providers |
There was a problem hiding this comment.
Is the duplicate message due to message "virtual package 'python' has no concrete package providers" being output to stdout and stderr? If so, why? If not, provide an explaination.
There was a problem hiding this comment.
The duplicate message was caused by a bug in GetAptPackages (line 131 in apt.go). The line errMsgs = append(errMsgs, strings.Join(errMsgs, "\n")) was appending all error messages back to the slice, then line 138 joined them again, creating duplicates. Fixed in commit c08f9f0 by removing the redundant line 131.
|
@copilot Please continue working on this PR. |
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
Summary
Fixed the issue where APT virtual packages with no concrete providers caused invalid package names to be cached instead of failing with a clear error message.
Changes Made
python) return "Reverse Provides:" which gets parsed as "Reverse=Provides:" packagegetNonVirtualPackagefunction insrc/internal/common/apt.goto detect and properly handle virtual packages with no providers"virtual package 'python' has no concrete package providers available"isVirtualPackagehelper function to centralize virtual package detection logicerrMsgs = append(errMsgs, strings.Join(errMsgs, "\n"))line that was causing error messages to be duplicatedTestNormalizedList_VirtualPackageWithNoProviders_StderrsErrorMessageapt_querybinaries with the fixpython) now fail with clear error (shown once, not duplicated)libz-dev→zlib1g-dev) resolve correctlyDesign Decisions
The code already automatically installs concrete packages when virtual packages have providers (preserving efficiency). When no providers exist, it fails with a clear error message to inform users they need to specify a valid package name. This approach:
Impact
Users will no longer experience silent failures where invalid packages get cached. Instead, they'll receive immediate, actionable error messages (shown once, clearly) when using virtual packages that have no concrete implementations.
Original prompt
This section details on the original issue you should resolve
<issue_title>APT no-installation candidates for package still saves to cache rather than failing with clear error message.</issue_title>
<issue_description>I have a Github Action running daily on a private repo which tries to run some quick tests to verify an (extremely old) application is working. July 7th and prior ran fine before the latest update for the Google URL shortener removal, but July 8th and onward have failed (undetected by my checks, as my scripts were still reporting success even though the apt dependencies were not present. oops).
It seems to be failing because of the
- Reverse=Provides:line is erroneously detecting as a package to install.E: Unable to locate package Reverse.I have tried to update my Action to use Ubuntu v24.04 but unfortunately the application code I am running has not been touched since ~2019ish and thus there are build errors on newer Ubuntu versions that are a headache for another day. I am hoping there could be a quick fix for this so that I can continue caching my apt installs without having to touch ~30 year old C/C++ code 🙏.
Here is the relevant part of my
ci.yml: