Skip to content

fix(image_uris): reject unsupported container_version instead of returning a bad URI - #6377

Merged
rsareddy0329 merged 2 commits into
aws:master-v2from
rsareddy0329:fix/image-uris-container-version-v2
Oct 5, 2026
Merged

rsareddy0329 merged 2 commits into
aws:master-v2from
rsareddy0329:fix/image-uris-container-version-v2

Conversation

@rsareddy0329

Copy link
Copy Markdown
Contributor

Issue #, if available: Fixes #3702

Description of changes:

image_uris.retrieve() concatenated a caller-supplied container_version into the image
tag without validation, so

image_uris.retrieve("pytorch", "us-west-2", version="1.12", image_scope="inference",
                    instance_type="ml.p3.8xlarge", container_version="1.1")
# -> 763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-inference:1.12-gpu-py38-1.1

returned a URI for an image that does not exist — the call silently succeeded with an
unpullable image (#3702). The "1.1" is a Deep Learning Containers release version, not
a tag build component.

container_version is only meaningful for frameworks whose tag carries a trailing build
component — declared in the config container_version map (which already overrides the
caller value), or appended by the graviton, neuron, HuggingFace and
pytorch-smp paths. For any other framework a caller-supplied container_version can
only produce a non-existent tag, so this raises a clear ValueError instead of returning
a broken URI.

This is the V2 (master-v2) counterpart of #6376.

Testing:

  • New test_retrieve_rejects_container_version_for_unsupported_framework: a plain framework
    with container_version raises; omitting it still returns the valid tag.
  • tests/unit/sagemaker/image_uris/ test_retrieve.py + test_graviton.py pass (102 passed),
    including the existing graviton (ubuntu20.04-sagemaker) and HuggingFace (cu110-ubuntu18.04)
    container_version tests. flake8 and black -l 100 clean on changed files.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

retrieve() concatenated a caller-supplied container_version into the image
tag with no validation, so e.g. retrieve("pytorch", version="1.12",
image_scope="inference", instance_type="ml.p3.8xlarge", container_version="1.1")
returned pytorch-inference:1.12-gpu-py38-1.1 -- an image that does not exist
(the "1.1" is a Deep Learning Containers release version, not a tag build
component). The call silently succeeded with an unpullable URI (aws#3702).

container_version is only meaningful for frameworks whose tag carries a
trailing build component: declared in the config container_version map (which
already overrides the caller value), or appended by the graviton, neuron,
HuggingFace and pytorch-smp paths. For any other framework a caller-supplied
container_version can only produce a non-existent tag, so raise a clear
ValueError instead of returning a broken URI.

This is the V2 (master-v2) counterpart of aws#6376.

Add a unit test; existing graviton and HuggingFace container_version tests
continue to pass.

Relates-to aws#3702
@rsareddy0329
rsareddy0329 requested a review from a team as a code owner October 1, 2026 22:01
@rsareddy0329
rsareddy0329 deployed to auto-approve October 1, 2026 22:54 — with GitHub Actions Active
The aws#3702 guard rejected a caller-supplied container_version for any
framework whose config has no container_version map and that is not
HuggingFace/graviton/neuron/pytorch-smp. That wrongly broke Spark:
PySparkProcessor/SparkJarProcessor call image_uris.retrieve("spark", ...,
container_version="v1"), and spark.json has no container_version map, so the
guard raised ValueError and broke Spark image retrieval
(test_processing.py::test_retrieve_image_uri).

Replace the ad hoc framework checks with an explicit
FRAMEWORKS_WITH_CONTAINER_VERSION_SUFFIX allowlist (huggingface, pytorch-smp,
spark) so the set of frameworks that legitimately append a container_version
is self-documenting, and add a Spark regression test.

Relates-to aws#3702
@rsareddy0329
rsareddy0329 deployed to auto-approve October 2, 2026 21:15 — with GitHub Actions Active
@rsareddy0329
rsareddy0329 merged commit 2d0804d into aws:master-v2 Oct 5, 2026
8 of 11 checks passed

This branch was successfully deployed

1 active deployment
auto-approve — f71ec7b9 Deployed Oct 2, 2026 by rsareddy0329 via wait-for-approval #245
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.

2 participants