← Back to issue list

apt cache: improve error handling when packages do not have candidates available (CRAFT-136) (CRAFT-218)

View original Github issue

Metadata

Project
snapcraft
Number
#3528
Type
pull request
State
merged
Author
cjp256
Labels
—
Created
Updated
Closed

Current evaluation

Merged #3528, adding missing APT candidate checks and limiting unmarking to relevant packages, preventing crashes when repositories expose no candidate.

Resolution: closed resolved

Reason: PR #3528 was merged with PackageNotFoundError guards and removal of the unnecessary full-package scan. The corresponding implementation was also merged in canonical/craft-parts#80 via commit 0d892afb.

Evaluated by: mr-cal-bot

No scores available.

Issue body

(1) Add some checks to ensure package.candidate is not None before using it. If it is None, when expected to not be None, raise a PackageNotFoundError with the name of the package in question. (2) Do not iterate over all packages when unmarking. This is the cause of https://forum.snapcraft.io/t/snapcraft-crash-when-esm-repositories-are-present/24587/8 where a package was being inspected that did not have an available candidate, causing Snapcraft to fail unnecessarily. Fixes SNAPCRAFT-2NE Fixes SNAPCRAFT-2H2 Fixes SNAPCRAFT-2BC Fixes SNAPCRAFT-277 Fixes SNAPCRAFT-263 Fixes SNAPCRAFT-1R4 Fixes SNAPCRAFT-1Q5 Fixes SNAPCRAFT-1DH Fixes a comment in unrelated bug report: LP: #1853682 Signed-off-by: Chris Patterson <chris.patterson@canonical.com> - [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [ ] Have you successfully run `./runtests.sh static`? - [ ] Have you successfully run `./runtests.sh tests/unit`? -----

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged #3528, adding missing APT candidate checks and limiting unmarking to relevant packages, preventing crashes when repositories expose no candidate.
stealth/space-bunny-alpha — closed resolved Merged #3528, adding missing APT candidate checks that raise PackageNotFoundError and limiting unmarking to marked packages, avoiding crashes from repositories without candidates.
stealth/space-bunny-alpha — closed resolved Merged in #3528: added APT candidate null checks that raise PackageNotFoundError and stopped unmarking from scanning every package, fixing crashes caused by unavailable candidates.
qwen/qwen3.6-35b-a3b — — Merged apt cache error handling that adds null checks for package candidates, preventing crashes when versions are unavailable. The change raises a clear PackageNotFoundError and optimizes unmarking logic, resolving multiple internal bug reports.
qwen3.6-35b-a3b-mtp-q6 — — Merged apt cache error handling improvements for packages lacking candidates. Adds None checks to raise PackageNotFoundError and optimizes iteration. Resolves multiple internal tickets and a Launchpad bug, verified by new spread tests.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-parts#80 (confidence 95%)

    Merged PR for CRAFT-219 carried the no-candidate handling and unmarking fix for the Snapcraft #3528 failure.

Related issues

Issue Project State Summary Similarity
#80 packages: handle packages with no candidate (CRAFT-219) craft-parts merged Merged craft-parts#80 via commit aa208282 (merge 0d892afb), adding APT candidate checks and avoiding all-package scans during unmarking to prevent ESM-related crashes.
77%
#1446 fix(apt_cache): set all candidate versions before marking packages craft-parts merged Merged as commit cf118b5f: apt_cache.mark_packages split into two passes so candidate versions are pinned before mark_install, fixing versioned interdependency resolution. Closes craft-parts#1444.
74%
#379 apt_cache: ignore unreadable files in /etc/apt craft-parts merged Merged #379 (commit 407d46eb), making AptCache skip unreadable files under /etc/apt; the fix shipped in craft-parts 1.19.0 and closed #378.
73%
#66 buildd base: configure apt to error on fetch failures (CRAFT-344) craft-providers merged Merged #66 (commits 9fd06eb/a56c2bb), configuring APT::Update::Error-Mode="any" so apt update fails on fetch errors instead of silently succeeding.
72%