← Back to issue list

Validity of `base` is not checked when using `--destructive-mode`

View original Github issue

Metadata

Project
snapcraft
Number
#4562
Type
issue
State
closed
Author
dilyn-corner
Labels
Created
Updated
Closed

Current evaluation

Resolved in snapcraft 8.1 via craft-application 2.0 and canonical/craft-application#263. Base validity is now enforced during destructive-mode builds, blocking invalid or unreleased bases.

Suggested action:

No scores available.

Issue body

### Bug Description When building a snap with `snapcraft --destructive-mode` (or setting the corresponding environment variable), the `base` of the snap is not checked. The `base` is installed as a prerequisite (`build-snap`) on the host system; so long as the base is a valid target to `snap install`, no additional checks are run. ### To Reproduce ``` mkdir test && cd test snapcraft init sed -i 's/base: core22/base: core24/' snap/snapcraft.yaml snapcraft --destructive-mode ``` ### Environment Any Ubuntu base, snapcraft 8.x. ### snapcraft.yaml ```shell name: my-snap-name # you probably want to 'snapcraft register <name>' base: core24 # the base snap is the execution environment for this snap version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' summary: Single-line elevator pitch for your amazing snap # 79 char long summary description: | This is my-snap's description. You have a paragraph or two to tell the most important story about your snap. Keep it under 100 words though, we live in tweetspace and your description wants to look good in the snap store. grade: devel # must be 'stable' to release into candidate/stable channels confinement: devmode # use 'strict' once you have the right plugs and slots parts: my-part: # See 'snapcraft plugins' plugin: nil ``` ### Relevant log output ```shell dilyn@Ares:~/test -> snapcraft --destructive-mode --verbosity=trace Starting Snapcraft 8.0.2.post14+git89961cfc Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240205-180421.093035.log' 2024-02-05 18:04:21.093 Starting Snapcraft 8.0.2.post14+git89961cfc 2024-02-05 18:04:21.093 Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240205-180421.093035.log' 2024-02-05 18:04:21.093 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'verbosity': 'trace', 'version': False, 'trace': False} filtered=['--destructive-mode'] 2024-02-05 18:04:21.094 Using default command: 'pack' 2024-02-05 18:04:21.094 General parsed sysargs: command='pack' args=['--destructive-mode'] 2024-02-05 18:04:21.094 Command parsed sysargs: Namespace(destructive_mode=True, use_lxd=False, debug=False, enable_manifest=True, manifest_image_information=None, bind_ssh=False, build_for=None, http_proxy=None, https_proxy=None, ua_token=None, enable_experimental_ua_services=False, enable_experimental_plugins=False, enable_experimental_extensions=False, enable_developer_debug=False, enable_experimental_target_arch=False, target_arch=None, provider=None, directory=None, output=None) 2024-02-05 18:04:21.095 lifecycle command: 'pack', arguments: Namespace(destructive_mode=True, use_lxd=False, debug=False, enable_manifest=True, manifest_image_information=None, bind_ssh=False, build_for=None, http_proxy=None, https_proxy=None, ua_token=None, enable_experimental_ua_services=False, enable_experimental_plugins=False, enable_experimental_extensions=False, enable_developer_debug=False, enable_experimental_target_arch=False, target_arch=None, provider=None, directory=None, output=None) 2024-02-05 18:04:21.095 command: pack, arguments: Namespace(destructive_mode=True, use_lxd=False, debug=False, enable_manifest=True, manifest_image_information=None, bind_ssh=False, build_for=None, http_proxy=None, https_proxy=None, ua_token=None, enable_experimental_ua_services=False, enable_experimental_plugins=False, enable_experimental_extensions=False, enable_developer_debug=False, enable_experimental_target_arch=False, target_arch=None, provider=None, directory=None, output=None) 2024-02-05 18:04:21.104 Created build plan: build-on: amd64 build-for: amd64 2024-02-05 18:04:21.105 CPU count (from process affinity): 24 2024-02-05 18:04:21.105 Invalid SNAPCRAFT_MAX_PARALLEL_BUILD_COUNT '' 2024-02-05 18:04:21.105 Running on amd64 for amd64 2024-02-05 18:04:21.106 Initializing parts lifecycle 2024-02-05 18:04:21.106 is_snap: True, SNAP_NAME set to snapcraft 2024-02-05 18:04:21.107 process my-part:Step.PULL 2024-02-05 18:04:21.107 add action my-part:Step.PULL(ActionType.RUN) 2024-02-05 18:04:21.107 process my-part:Step.BUILD 2024-02-05 18:04:21.107 add action my-part:Step.BUILD(ActionType.RUN) 2024-02-05 18:04:21.107 process my-part:Step.STAGE 2024-02-05 18:04:21.107 add action my-part:Step.STAGE(ActionType.RUN) 2024-02-05 18:04:21.108 process my-part:Step.PRIME 2024-02-05 18:04:21.108 add action my-part:Step.PRIME(ActionType.RUN) 2024-02-05 18:04:21.108 Installing build-packages 2024-02-05 18:04:21.108 Installing build-snaps 2024-02-05 18:04:21.528 Installing snap: core24 2024-02-05 18:04:24.157 verify plugin environment for part 'my-part' 2024-02-05 18:04:24.158 Pulling my-part 2024-02-05 18:04:24.158 execute action my-part:Action(part_name='my-part', step=Step.PULL, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-02-05 18:04:24.166 Building my-part 2024-02-05 18:04:24.166 execute action my-part:Action(part_name='my-part', step=Step.BUILD, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-02-05 18:04:24.166 load state file: /home/dilyn/test/parts/my-part/state/pull 2024-02-05 18:04:24.203 remove directory /home/dilyn/test/parts/my-part/build 2024-02-05 18:04:24.205 Executing PosixPath('/home/dilyn/test/parts/my-part/run/build.sh') 2024-02-05 18:04:27.739 Staging my-part 2024-02-05 18:04:27.740 execute action my-part:Action(part_name='my-part', step=Step.STAGE, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-02-05 18:04:27.759 Priming my-part 2024-02-05 18:04:27.759 execute action my-part:Action(part_name='my-part', step=Step.PRIME, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None)) 2024-02-05 18:04:27.779 patch_elf: not enabled for part 'my-part' 2024-02-05 18:04:27.780 Extracting and updating metadata... 2024-02-05 18:04:27.780 Copying snap assets... 2024-02-05 18:04:27.780 Generating snap metadata... 2024-02-05 18:04:27.782 Generated snap metadata 2024-02-05 18:04:27.782 Generating snap manifest... 2024-02-05 18:04:27.782 load state file: /home/dilyn/test/parts/my-part/state/pull 2024-02-05 18:04:27.786 load state file: /home/dilyn/test/parts/my-part/state/prime 2024-02-05 18:04:27.790 Generated snap manifest 2024-02-05 18:04:27.800 Reading snap metadata... 2024-02-05 18:04:27.801 Running linters... 2024-02-05 18:04:27.801 Running linter: classic 2024-02-05 18:04:27.801 Running linter: library 2024-02-05 18:04:27.806 pack_snap: output=None, compression='xz' 2024-02-05 18:04:27.807 pack_snap: check skeleton 2024-02-05 18:04:27.824 Creating snap package... 2024-02-05 18:04:27.824 Pack command: ['snap', 'pack', '--filename', 'my-snap-name_0.1_amd64.snap', '--compression', 'xz', PosixPath('/home/dilyn/test/prime'), PosixPath('/home/dilyn/test')] 2024-02-05 18:04:27.850 Created snap package my-snap-name_0.1_amd64.snap ``` ### Additional context In the specific case of using a dev-level base (as core24 is), this behavior should at least be locked behind `grade: devel` so as to avoid allowing publishing potentially broken snaps to stable or candidate tracks in the store. It may also be preferable to disallow using `base: coreXX` under any circumstances when that base has yet to be officially released (that is to say, while its usage when not using `--destructive-mode` is still guarded by a `build-base` check).

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Resolved in snapcraft 8.1 via craft-application 2.0 and canonical/craft-application#263. Base validity is now enforced during destructive-mode builds, blocking invalid or unreleased bases.
qwen/qwen3.6-35b-a3b Fixed in Snapcraft 8.1 via craft-application 2.0. Base validity is now properly enforced during destructive mode builds, preventing invalid bases from being accepted without checks.
qwen/qwen3.6-35b-a3b Resolved in snapcraft 8.1 via craft-application 2.0 and PR #263. Base validity is now enforced during destructive mode builds, preventing invalid or unreleased bases.
qwen3.6-35b-a3b-mtp-q6 Resolved in snapcraft 8.1 via craft-application 2.0. Base validity is now enforced during destructive-mode builds, preventing invalid or unreleased bases from bypassing checks. Fixed via canonical/craft-application#263.
qwen3.6-35b-a3b-mtp-q6 Fixed in snapcraft 8.1 via craft-application 2.0. Base validity is now enforced for core24 snaps, resolving the destructive-mode bypass. Closed via canonical/craft-application#263.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#4972 Cannot create a snap with base:bare in destructive mode snapcraft open Snapcraft 8.3.2 fails with 'cannot determine build-for architecture' when building a base:bare snap in destructive mode without build-base. Maintainer confirmed build-base is required for bare and plans an earlier, clearer validation error.
73%
#761 models/project.py: do not check for base when build-base: devel craft-application closed Rejected. Maintainers kept the default base validation for all crafts. They advised overriding _validate_devel_base in snapcraft to support the gadget snap use case instead.
72%
#4721 feat: validate devel bases with craft-application snapcraft closed Superseded by pull request #4796. The changes to validate devel bases with craft-application and remove the build-base: devel requirement for core24 snaps were closed in favor of the newer implementation.
72%
#1839604 build-base seems broken snapcraft (launchpad) open Seven-year-old question about snapcraft rejecting 'base: bare' with 'build-base: core18' via a confusing validation error. No maintainer response; validation was rewritten in snapcraft 8.x, where build-base is now required for bare bases, so the reported combination is now valid.
72%