Repository navigation
Keep full tag when parsing image names with extra colons - #12107
SamuelAdigos wants to merge 1 commit into
Conversation
`DockerImageName.parse("neo4j:neo4j:4.4")` silently dropped everything
after the second colon. The tag is now everything after the first colon
of the remote name, consistent with the tag-and-digest branch, so the
malformed name is preserved and rejected by `assertValid()`.
A trailing colon (`myname:`) now fails with a descriptive
`IllegalArgumentException` instead of an `ArrayIndexOutOfBoundsException`.
Fixes testcontainers#5190
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The change preserves malformed image-name input for validation and improves the empty-tag error; no material merge risk was identified. Pre-merge checks |
|
Fixes #5190
DockerImageName.parse("neo4j:neo4j:4.4")silently dropped everything after the second:, yieldingneo4j:neo4j.The malformed name passed
assertValid(), and any later error referred to an image name the user never wrote.The tag is now everything after the first
:of the remote name (split(":", 2)), matching how the tag-and-digest branchalready parses it (see
testMalformedTagWithExtraColonIsRejected). The full name is preserved andassertValid()rejectsthe malformed tag, since
:is not allowed in Docker tags.A trailing colon (
myname:) previously failed with anArrayIndexOutOfBoundsException; it now fails with a descriptiveIllegalArgumentExceptioninstead of producing an empty tag (which would otherwise reach the pull withtag="").Note: a malformed name such as
postgres:16:alpinepreviously resolved silently topostgres:16; it will now fail whenDocker is asked for the invalid tag.
I kept the change minimal rather than aligning the whole parser with the Docker reference grammar, as discussed in the
issue, to avoid rejecting names that are accepted today.
Tests
DockerImageNameTest.InvalidNamestestExtraColonInTagIsNotDroppedandtestEmptyTagIsRejected./gradlew :testcontainers:spotlessApply :testcontainers:checkstyleMain :testcontainers:checkstyleTest :testcontainers:japicmptestMatrixlocally (core, all modules and examples). The only failures were environment-related(arm64 host, Rancher Desktop) and reproduce identically on
mainwithout this change.Summary by CodeRabbit