Build --dry-run combined with --push raises an unhandled RuntimeError

Open Beginner friendly
#286 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
69/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start at the CLI handling for build --dry-run --push in pycontainer/cli.py (the traceback points near line 693), then trace the dry-run and push behavior into pycontainer/builder.py around push(). Check the existing CLI tests for dry-run and push combinations. Done when this combination either completes a no-mutation preview or returns an actionable usage error without an unhandled traceback.

Written by the indexing model from the issue text.

Description

bug build priority:p2 release:backlog type:bug ux

Summary

Combining the documented build --dry-run and --push options raises an unhandled exception after printing a build plan. The documentation describes --dry-run as a preview without creating artifacts, but does not define the combined flags' behavior.

Environment

  • pycontainer-build 0.4.0, release v0.4.0, commit 241887ed82e2f884c030c954fc5e813d67e8c43f
  • Wheel SHA-256: 775345dd1c17890ce4d4598c87cfd52bf6174d25af049ea09312ad6b3562be7f
  • Windows 11 x64, Python 3.12.10, uv 0.13.9; isolated home, Docker configuration and caches

Reproduction

Create pyproject.toml:

[project]
name = "dogfood-zero"
version = "0.1.0"
requires-python = ">=3.12"
description = "Synthetic zero-config dogfood application"

[project.scripts]
dogfood-zero = "zero_runtime:main"

Create src/zero_runtime.py:

import json
import os
import platform
import sys


def main():
    print(json.dumps({
        "application": "zero-runtime",
        "mode": os.environ.get("DOGFOOD_MODE", "zero"),
        "python": platform.python_version(),
        "implementation": platform.python_implementation(),
        "executable": os.path.basename(sys.executable),
    }, sort_keys=True))


if __name__ == "__main__":
    main()

Run from the project directory:

pycontainer build --tag docker.io/spboyer/dogfood-never-publish:v1 --dry-run --push

Expected

Either provide a successful no-mutation preview or reject the combination as a usage error with an actionable diagnostic. Neither behavior should raise an unhandled traceback.

Actual

The command exits 1 and reports:

DRY RUN: Would build image docker.io/spboyer/dogfood-never-publish:v1
Traceback (most recent call last):
  ... pycontainer/cli.py, line 693, in main
    pushed = builder.push(**push_options)
  ... pycontainer/builder.py, line 1195, in push
    raise RuntimeError("Must call build() before push()")
RuntimeError: Must call build() before push()

The output also includes Built: docker.io/spboyer/dogfood-never-publish:v1. The existing local OCI layout was unchanged and no registry mutation occurred. This makes the documented preview and push flags unsuitable for a combined preflight and exposes an internal traceback instead of a clear user-facing result.

Related work

#258 addresses Windows image target rejection and references the unbuilt-image push guard; it does not address --dry-run --push.

Dominant language
Python
Stars
10
Forks
1
Avg merge
1d 19h
Merged PRs (30d)
129

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spboyer/pycontainer-build

All issues in spboyer/pycontainer-build

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.