Bakery: Soften error or fall back when no version has `latest: true` during `create version`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia da posit_bakery/cli/create.py e posit_bakery/config/config.py intorno a create_version, quindi segui la risoluzione dell’OS e il rendering dei template in version.py. Riproduci il problema con il comando documentato bakery create version e ispeziona il percorso di pulizia delle versioni esistenti. Il lavoro è completo quando il caso no-latest ricade su una versione esistente documentata oppure segnala un errore CLI chiaro e risolvibile, senza esporre il traceback di Jinja né lasciare un output parziale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When running bakery create version <image> <new-version> against an image where no existing version is marked latest: true, Bakery fails to populate the OS configuration for template rendering. This surfaces as an opaque Jinja2 'dict object' has no attribute 'OS' rendering error rather than a clear, actionable message — and there is no fallback to copy the OS configuration from an existing (non-latest) version.
Reproduction
In a repository configured with an image that has at least one prior version, but where no version sets latest: true, run:
bakery create version workbench-for-google-cloud-workstations '2026.04.0+526.pro2'
This was reproduced against posit-dev/images-specialized on branch workbench-2026.04. The relevant image block in bakery.yaml has a single existing version (2026.01.2+418.pro1) with an OS entry (Ubuntu 24.04, primary: true) but no latest: true on the version itself.
Observed behavior
Bakery emits warnings about the missing OS, then a template render error referencing an undefined OS attribute on the rendering context, followed by a traceback. The newly-created version directory is left on disk as well (the cleanup shutil.rmtree only fires when existing_version_dir was False at start, but in some cases the partial output persists).
Full output / stacktrace
[14:24:23] INFO Loading Bakery config from config.py:374
/home/ianp/Projects/images-specialized/bakery.
yaml
WARNING No OSes defined for image version version.py:178
'2026.04.0+526.pro2'. At least one OS should
be defined for complete tagging and labeling
of images.
WARNING No OS marked as primary for image version version.py:241
'2026.04.0+526.pro2'. At least one OS should
be marked as primary for complete tagging and
labeling of images.
ERROR Failed to render template version.py:502
Containerfile.ubuntu2404.jinja2 for image
'workbench-for-google-cloud-workstations'
version '2026.04.0+526.pro2' variant
'Standard'
ERROR Failed to render template version.py:502
Containerfile.ubuntu2404.jinja2 for image
'workbench-for-google-cloud-workstations'
version '2026.04.0+526.pro2' variant
'Minimal'
ERROR Failed to create version files for image config.py:555
'workbench-for-google-cloud-workstations'
version '2026.04.0+526.pro2'.
ERROR Error creating version create.py:242
╭──── Traceback (most recent call last) ─────╮
│ posit_bakery/cli/create.py:233 in version │
│ c.create_version(...) │
│ posit_bakery/config/config.py:559 in │
│ create_version │
│ raise e │
│ posit_bakery/config/config.py:553 in │
│ create_version │
│ new_version.render_files(...) │
╰────────────────────────────────────────────╯
Error rendering template
workbench-for-google-cloud-workstations/template/Containerfile.ubuntu2404.jinja2:
'dict object' has no attribute 'OS'
- Image: workbench-for-google-cloud-workstations
- Version: 2026.04.0+526.pro2
- Variant: Standard
- Destination: workbench-for-google-cloud-workstations/2026.04.0+526.pro2/Containerfile.ubuntu2404.std
Error rendering template
workbench-for-google-cloud-workstations/template/Containerfile.ubuntu2404.jinja2:
'dict object' has no attribute 'OS'
- Image: workbench-for-google-cloud-workstations
- Version: 2026.04.0+526.pro2
- Variant: Minimal
- Destination: workbench-for-google-cloud-workstations/2026.04.0+526.pro2/Containerfile.ubuntu2404.min
2 template(s) returned errors
❌ Failed to create version 'workbench-for-google-cloud-workstations/2026.04.0+526.pro2'
Why this is friction
The user's mental model is reasonable: "I have one prior version with an OS configured — when I add a new version, copy that forward." Today Bakery only copies forward from the version explicitly marked latest: true, so a config that has never declared a latest version produces a stack trace instead of either a useful error or a working render.
Suggested directions
Either (or both) of these would close the gap:
- Soften the error. When OS resolution fails for a new version, surface a clear, actionable message at the CLI layer — e.g. "no version of
<image>is markedlatest: true; cannot infer OS configuration. Either mark a prior version as latest or specify OSes on the new version" — instead of letting a JinjaAttributeErrorescape. - Fallback sequence. When no version has
latest: true, fall back to copying the OS configuration from another existing version (e.g. the most recent by version order, or the only one if there is exactly one). This matches the implicit "most recent is latest" assumption users tend to bring.
Direction (2) is the more user-friendly fix; (1) is the minimum bar regardless of whether (2) lands.
Environment
- Bakery checkout:
~/Projects/images-shared-ordered-push/posit-bakery(per the traceback paths) - Repo under test:
posit-dev/images-specialized, branchworkbench-2026.04
- Lingua principale
- Python
- Stelle
- 2
- Fork
- 0
- Merge medio
- 2g 23h
- PR unite (30g)
- 20
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di posit-dev/images-shared
-
cvp:0 docker tdp:1
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
posit-dev/images-shared#757 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug cvp:0 docker priority/medium python tdp:1
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
posit-dev/images-shared#685 ·
I maintainer di solito rispondono entro 1 giorno
-
slack-build-notify: no persisted alert state — causes suppressed repeat-failure and recovery alertsApertabug cicd cvp:0 docker needs discussion observability tdp:2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
posit-dev/images-shared#677 ·
I maintainer di solito rispondono entro 1 giorno
-
cvp:0 docker tdp:2 tech debt
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
posit-dev/images-shared#795 ·
I maintainer di solito rispondono entro 1 giorno
-
cicd cvp:0 docker enhancement tdp:2
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
posit-dev/images-shared#773 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di posit-dev/images-shared
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-2 giorni Idoneità per principianti 70/100
-
FingerprintSplitter raises ZeroDivisionError when int(frac_train * len(dataset)) floors to zeroAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
lmstudio-ai/mlx-engine#376 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pyiron/bagofholding#166 ·