Skip to content

Fix template replacement producing invalid image reference with digests#3440

Open
honnix wants to merge 1 commit into
masterfrom
fix-digest-separator
Open

Fix template replacement producing invalid image reference with digests#3440
honnix wants to merge 1 commit into
masterfrom
fix-digest-separator

Conversation

@honnix

@honnix honnix commented Jun 16, 2026

Copy link
Copy Markdown
Member

Tracking Issue

Closes flyteorg/flyte#7531

Why are the changes needed?

When an image reference with a digest is passed to pyflyte register --image (e.g. gcr.io/project/image:tag@sha256:digest), the registered task spec contains an invalid image reference with : instead of @ before the digest.

The root cause is in get_registerable_container_image(): when replacing {{.image.<name>.version}} in a template, the version value is substituted directly but the separator before the placeholder is always : (hardcoded in the template). When version is a digest (e.g. sha256:...), the separator should be @.

Example:

  • Template: {{.image.default.fqn}}:{{.image.default.version}}
  • Image: gcr.io/project/image:tag@sha256:abc123
  • Before fix: gcr.io/project/image:tag:sha256:abc123 (invalid)
  • After fix: gcr.io/project/image:tag@sha256:abc123 (valid)

This also affects digest-only references (no tag):

  • Image: gcr.io/project/image@sha256:abc123
  • Before fix: gcr.io/project/image:sha256:abc123 (invalid)
  • After fix: gcr.io/project/image@sha256:abc123 (valid)

What changes were proposed in this pull request?

In get_registerable_container_image(), when the resolved version is a digest (contains :), replace the preceding : separator with @ in the output. Tags never contain :, so the check is unambiguous.

How was this patch tested?

Added test cases for both scenarios to test_container_image_conversion:

  1. Digest-only image (fqn without tag) with : template separator
  2. Tag+digest image (fqn contains baked-in tag) with : template separator — the real-world case from _parse_image_identifier("repo:tag@sha256:...")

Existing tests continue to pass.

When an image with a digest is used (e.g. image:tag@sha256:...), the
template replacement for {{.image.<name>.version}} hardcodes : as the
separator. Since version returns the digest, this produces
image:tag:sha256:... (invalid) instead of image:tag@sha256:... (valid).

Fix by detecting when version is a digest (contains :) and replacing
the preceding : separator with @ in the output.

Fixes flyteorg/flyte#7531

Signed-off-by: Hongxin Liang <honnix@users.noreply.github.com>
@honnix honnix force-pushed the fix-digest-separator branch from c82da4c to 6997496 Compare June 16, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flytekit] Template replacement produces invalid image reference when using tag@digest format

1 participant