← Back to issue list

repo: catch error updating the package cache

View original Github issue

Metadata

Project
snapcraft
Number
#2079
Type
pull request
State
merged
Author
kalikiana
Labels
—
Created
Updated
Closed

Current evaluation

PR #2079 by kalikiana merged as commit d879b2e3a, adding CacheUpdateFailedError, catching apt.cache.FetchFailedException and clearing the index on hashsum mismatch. Fixed #2029, #2030 and LP #1747715.

Resolution: closed resolved

Reason: The PR was merged into snapcraft as commit d879b2e3a with 2 approving reviews; it introduced CacheUpdateFailedError in the errors module and apt cache-update failure handling in snapcraft/repo/deb.py, closing issues #2029 and #2030 and LP bug #1747715.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)? - [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh unit`? ----- This PR handles errors when updating the package cache, such as a hash mismatch or unresolved hostnames. The apt API doesn't distinguish these, so unfortunately we can't be very specific here but need to rely on the output we get before the error is raised. If the error is a hashsum mismatch, the index will be cleared and Snapcraft will continue. Fixes: #2029 #2030 Fixes: [LP: #1747715](https://bugs.launchpad.net/snapcraft/+bug/1747715) The following tests are added/ modified: - tests.unit.test_errors - To verify CacheUpdateFailedError - tests.unit.repo.test_deb.UbuntuTestCase.test_cache_update_failed - To verify that an `apt.cache.FetchFailedException` is handled as a proper error. - tests.unit.repo.test_deb.UbuntuTestCase.test_cache_hashsum_mismatch - To verify that a hashsum error will be caught and proceed after clearing the index. I locally ran the tests: - `./runtests.sh tests/unit` with unrelated failures in [tests.unit.test_lifecycle.CoreSetupTestCase.test_core_setup_if_docker_env](https://bugs.launchpad.net/snapcraft/+bug/1752576), `tests.unit.test_mangling.TestClearExecstack.test_execstack_clears` and `tests.unit.test_elf`. - `./runtests.sh tests/integration` with one unrelated failure in [tests.integration.general.test_parser.TestParserWikis](https://bugs.launchpad.net/snapcraft/+bug/1752580) - `./runtests.sh static`: Everything passed Manual test steps: - cd tests/integration/snaps/go-hello - Add a stage package: stages-packages: [appstream] - Modify `/etc/apt/sources.list` so that it can't update successfully, such as by adding an invalid URL. - snapcraft - Observe the error "Failed to update the package cache: Some files could not be downloaded. Check that the sources on your host are configured correctly.".

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved PR #2079 by kalikiana merged as commit d879b2e3a, adding CacheUpdateFailedError, catching apt.cache.FetchFailedException and clearing the index on hashsum mismatch. Fixed #2029, #2030 and LP #1747715.
stealth/space-bunny-alpha — closed resolved Merged as commit d879b2e3a: snapcraft now catches apt cache-update failures, raising CacheUpdateFailedError and clearing the index on hashsum mismatch. Fixes #2029, #2030, LP #1747715.
stealth/space-bunny-alpha — closed resolved Merged in snapcraft PR #2079 as commit d879b2e3a, handling apt cache-update errors and clearing the index after hashsum mismatches. Fixes #2029, #2030 and LP #1747715.
stealth/space-bunny-alpha — closed resolved Merged #2079 in d879b2e3, improving apt cache update errors and recovering from hash mismatches by clearing the package index.
qwen/qwen3.6-35b-a3b — — Merged. Catches apt package cache update errors like hash mismatches and host resolution failures. Fixes #2029, #2030, and LP: #1747715 by handling exceptions, clearing the index on hash failures, and allowing Snapcraft to proceed. Includes test updates.
qwen3.6-35b-a3b-mtp-q6 — — Merged fix that catches package cache update errors like hash mismatches and host resolution failures. It clears the index on hash mismatches to allow continuation, adds unit tests, and resolves #2029, #2030, and LP: #1747715.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: snapcraft#2029 (confidence 97%)

    'Proper error for apt hash sum mismatches' — closed by this PR; maintainer kyrofa confirmed it fixes #2029.

  • Likely Fixed By: snapcraft#2030 (confidence 90%)

    'Properly invalidate the cache if sources change' — resolved via index clearing after hashsum mismatch.

Related issues

Issue Project State Summary Similarity
#2029 Proper error for apt hash sum mismatches snapcraft closed Fixed by merged PR #2079 (commit d879b2e3a), which added CacheUpdateFailedError, caught apt's FetchFailedException and cleared the index on hashsum mismatch, closing #2029, #2030 and LP #1747715.
78%