Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Bakery: Soften error or fall back when no version has `latest: true` during `create version`

Aperta
#511 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
cli

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

cvp:1 docker tdp:1

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:

  1. 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 marked latest: true; cannot infer OS configuration. Either mark a prior version as latest or specify OSes on the new version" — instead of letting a Jinja AttributeError escape.
  2. 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, branch workbench-2026.04
Lingua principale
Python
Stelle
2
Fork
0
Merge medio
2g 23h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di posit-dev/images-shared

Tutte le issue di posit-dev/images-shared

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.