remote build: fails if `--platform` or `--build-for` are passed with no `platforms` or `architectures` defined
Metadata
Current evaluation
Closed pending implementation per defined scope: restrict --platform/--build-for flags to projects without explicit platform definitions and block their use for core22 snaps. Tracked in Jira CRAFT-3070.
Suggested action: —
No scores available.
Issue body
### Bug Description
1. If `--platform` or `--build-for` are passed and the target is not in the build plan, snapcraft will fail
2. Snapcraft accepts `--platform` for remote building core22 snaps, which shouldn't be allowed
### To Reproduce
snapcraft remote-build --launchpad-accept-public-upload --platform arm64 --verbosity verbose
### Environment
snapcraft 8.2.12
### snapcraft.yaml
```shell
name: test-snap
base: core22
version: "1.0"
summary: test snap
description: test snap
confinement: strict
parts:
my-part:
plugin: nil
```
### Relevant log output
```shell
2024-06-27 07:38:50.651 Starting snapcraft, version 8.2.12
2024-06-27 07:38:50.651 Log verbosity level set to BRIEF
2024-06-27 07:38:50.651 Configuring application...
2024-06-27 07:38:50.651 Preparing application...
2024-06-27 07:38:50.652 Build plan: platform=arm64, build_for=None
2024-06-27 07:38:50.652 Loading project file '/tmp/bar/snapcraft.yaml'
2024-06-27 07:38:50.660 Platform 'arm64' not found in the project definition.
2024-06-27 07:38:50.660 Detailed information: Valid platforms are: amd64.
2024-06-27 07:38:50.660 Full execution log: '/home/developer/.local/state/snapcraft/log/snapcraft-20240627-073850.650481.log'
```
### Additional context
Reported by @tomponline in https://chat.canonical.com/canonical/pl/um8c4px4qbdw9j498gzsu68itw
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Closed pending implementation per defined scope: restrict --platform/--build-for flags to projects without explicit platform definitions and block their use for core22 snaps. Tracked in Jira CRAFT-3070. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed by implementing validation to restrict --platform and --build-for flags to projects without predefined architectures, and blocking their use for core22 snaps. Resolved via CRAFT-3070. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed with a defined scope to restrict --platform and --build-for flags to projects lacking build plan definitions, and to block --platform for core22 snaps. Tracked via Jira CRAFT-3070. No implementation or merge documented. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed after implementing validation to restrict --platform and --build-for flags to projects without predefined platforms or architectures. The fix also blocks --platform usage for core22 snaps, resolving the remote build failures. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without a fix. Maintainer defined scope to restrict --platform/--build-for flags to projects lacking explicit definitions and block core22 usage. Tracked internally as CRAFT-3070. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #5387 Warn if `--platform` is used for remote builds | snapcraft | open | Enhancement: make snapcraft remote-build error when --platform is passed and recommend --build-for, since --platform was dropped in 8.7.0 with no in-tool notice. Triaged by maintainer; no implementation yet. | |
| #5859 Non-list `build-for` values are no longer allowed | snapcraft | open | snapcraft 8.13.0 rejects valid non-list build-for values (e.g. build-for: amd64) in core22 platforms, raising an unhelpful RuntimeError instead of treating the string as a single-entry list. Triaged, open, no fix yet. |