Reject incomplete image specs in ImagePath - #2682
Open
abrarshivani wants to merge 1 commit into
Open
Conversation
5 tasks
tariq1890
reviewed
Jul 27, 2026
abrarshivani
force-pushed
the
imagepath-validation
branch
from
July 27, 2026 18:37
331b892 to
4c09df4
Compare
abrarshivani
marked this pull request as ready for review
July 27, 2026 18:41
abrarshivani
requested review from
cdesiniotis,
karthikvetrivel,
rahulait,
rajathagasthya and
shivamerla
as code owners
July 27, 2026 18:41
tariq1890
reviewed
Jul 27, 2026
tariq1890
enabled auto-merge
July 27, 2026 20:02
tariq1890
disabled auto-merge
July 27, 2026 20:02
Contributor
|
Can you squash the commit history? |
abrarshivani
force-pushed
the
imagepath-validation
branch
from
July 27, 2026 20:07
685eb4a to
7455df7
Compare
tariq1890
approved these changes
Jul 27, 2026
rahulait
reviewed
Jul 27, 2026
Contributor
Author
|
@rahulait PTAL. I have addressed the comments. |
rahulait
approved these changes
Jul 27, 2026
When a CR component sets repository or version but leaves repository, image or version empty, ImagePath/imagePath previously concatenated the parts into a structurally invalid reference such as "/image:tag", "repo/:tag" or "repo/image:", which only failed much later at image pull with an opaque error. Validate the branch that builds "repo/image:tag"/"@digest" and return a clear error when repository, image or version is empty, in both image.ImagePath (internal/image) and the duplicated api/nvidia/v1 imagePath used by v1.ImagePath. The error uses %s (not %q) so the field values stay readable in the operator's JSON logs. The kbld/carvel passthrough (repository and version both empty) and the env-var fallback are unchanged. Add tests covering the valid tag/digest, kbld passthrough, env fallback, all-empty error, incomplete-spec and unsupported-type paths. Signed-off-by: Abrar Shivani <ashivani@nvidia.com>
abrarshivani
force-pushed
the
imagepath-validation
branch
from
July 27, 2026 21:45
2ea4504 to
7dbfffc
Compare
tariq1890
approved these changes
Jul 27, 2026
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.
Description
ImagePath(internal/image) and its duplicateimagePath(api/nvidia/v1, used byv1.ImagePath) build a component's image reference from the CR'srepository/image/versionfields. Whenrepositoryorversionis set (so the CR branch is taken) butrepositoryorimageis empty, they previously concatenated the parts into a structurally invalid reference —"/image:tag","repo/:tag", or"/@sha256:..."— which then failed much later at image-pull time with an opaque error.This change makes both functions fail fast with a clear error when
repositoryorimageis empty in that branch:The kbld/carvel passthrough (
repositoryandversionboth empty →imageused verbatim) and the env-var fallback are unchanged.Tests
internal/image:TestImagePath_ValidSpec(fully-specified specs still resolve) andTestImagePath_InvalidSpec(incomplete specs are rejected, and an env value does not rescue a partial CR spec).api/nvidia/v1:TestImagePathcovering valid, kbld, incomplete-spec and unsupported-type paths.Split out of #2656 (test-coverage PR) per review, so the validation logic is tracked on its own. Affected suites (
api,controllers,internal/state) pass unchanged — no caller relied on the malformed-path behavior.Checklist
make lint)make validate-generated-assets)make validate-modules)Testing