<#7531 [flytekit] Template replacement produces in...
# flyte-github
a
#7531 [flytekit] Template replacement produces invalid image reference when using tag@digest format Issue created by honnix Bug Report Component: flytekit (v1.16.23) Description When an image reference with both tag and 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:
gcr.io/project/image:tag:sha256:digest
. Root Cause The issue is in the interaction between
_parse_image_identifier()
, the
Image
class, and template replacement in `get_registerable_container_image()`: 1.
_parse_image_identifier("gcr.io/project/image:tag@sha256:abc123")
splits on
@
first: •
fqn = "gcr.io/project/image:tag"
(tag baked into fqn) •
digest = "sha256:abc123"
•
tag = None
2.
Image.version
returns
self.digest or self.tag
=
"sha256:abc123"
3. When a container task uses the template
{{.image.default.fqn}}:{{.image.default.version}}
, the replacement produces: •
"gcr.io/project/image:tag"
+
:
+
"sha256:abc123"
• =
"gcr.io/project/image:tag:sha256:abc123"
— invalid reference The
Image.full
property handles this correctly (
f"{self.fqn}@{self.digest}"
), but the template replacement path hardcodes
:
between
fqn
and
version
without checking whether
version
is a digest. Steps to Reproduce pyflyte register \ --image "gcr.io/my-project/my-workflow:1234-abc@sha256:6b107220f2d7e16c0d13b641ebbc1179fe7f0fbbae622a1de212220d7fa2ffa2" \ --project my-project \ --domain production \ --version v1 \ my_workflow/ The registered task will have the container image set to:
Copy code
gcr.io/my-project/my-workflow:1234-abc:sha256:6b107220f2d7e16c0d13b641ebbc1179fe7f0fbbae622a1de212220d7fa2ffa2
Which Kubernetes rejects:
Copy code
Failed to apply default image tag "...": couldn't parse image name "...": invalid reference format
Expected Behavior The image reference should preserve the
@
separator:
Copy code
gcr.io/my-project/my-workflow:1234-abc@sha256:6b107220f2d7e16c0d13b641ebbc1179fe7f0fbbae622a1de212220d7fa2ffa2
Suggested Fix In
get_registerable_container_image()
(
flytekit/core/python_auto_container.py
), when replacing
{{.image.<name>.version}}
, use
@
as the separator if
version
is a digest (starts with
sha256:
), or use
Image.full
instead of separate `fqn`/`version` template replacement. Version flytekit v1.16.23 flyteorg/flyte