fix(image-ref): preserve digest and tag refs in PYTHON_EXECUTOR_DOCKER_IMAGE#36
Merged
Danelegend merged 1 commit intoMay 18, 2026
Conversation
…R_IMAGE `_ensure_docker_image_available` (app/main.py) and `DockerExecutor.check_health` (app/services/executor_docker.py) both unconditionally appended `:latest` to whatever value `PYTHON_EXECUTOR_DOCKER_IMAGE` held. When an operator sets that env var to a digest reference (e.g. `repo@sha256:abc...`) for reproducible deploys, the resulting `repo@sha256:abc...:latest` is invalid Docker syntax: image lookup fails, the FastAPI lifespan aborts, and the container crashloops. Refactor both call sites to use a new `normalize_image_ref` helper. The helper returns the reference unchanged when it already carries a tag (`:` after the last `/`) or a digest (`@`), and only appends `:latest` for bare repositories. Registry ports are handled correctly because a `:` before the last `/` is a port separator, not a tag. Coverage added in tests/integration_tests/test_image_ref.py: * bare repo / namespaced repo / registry/repo all gain :latest * tagged refs unchanged at every nesting level * digest refs unchanged at every nesting level * registry-with-port variants (port + bare, port + tag, port + digest) * idempotence Refs onyx-dot-app#35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #35.
What
_ensure_docker_image_available(code-interpreter/app/main.py:44) andDockerExecutor.check_health(code-interpreter/app/services/executor_docker.py:88) both unconditionally appended:latestto whatever valuePYTHON_EXECUTOR_DOCKER_IMAGEheld:This is correct when the env var holds a bare repository like
onyxdotapp/python-executor-sci. It breaks when the operator wants to pin the executor image to a specific digest for reproducibility:The resulting
repo@sha256:462c2fb0…:latestis malformed; image lookup fails, the FastAPI lifespan aborts, and the container goes into a restart loop.Fix
Extracts a
normalize_image_ref(ref)helper in a new modulecode-interpreter/app/image_ref.py. The helper:@(digest reference).:after the rightmost/(tag reference).:latest(bare repository — preserves the previous default).Care is taken with registry ports:
registry.example.com:5000/owner/repohas a:before the last/, which is a port separator and must not be confused with a tag.Both call sites in
main.pyandexecutor_docker.pyare updated to use the helper.Tests
New
code-interpreter/tests/integration_tests/test_image_ref.pycovers::latestappendedAll 10 cases verified locally.
Verification
ruff checkandruff format --checkpass on the touched files. mypy is configured strictly upstream — all helpers carry full type annotations (str -> str); imports are organized so isort/ruff are happy.No behavioral change for operators using the default bare-repo configuration:
normalize_image_ref("onyxdotapp/python-executor-sci")still producesonyxdotapp/python-executor-sci:latest, byte-identical to the priorf"{self.image}:latest"output.