Skip to content

ModelMapper.processJarPackage breaks on paths containing '+' #4710

Closed

Description

@laureanobrs

Describe the bug

The ModelMapper.processJarPackage method uses URLDecoder.decode, which turns + into spaces, producing an invalid filesystem path.

That causes ModelMapper.initModelMap() to fail, so the prebuilt model map is left empty for built-in resources like v1/ConfigMap.

This use case stems from Bazel 8, where the format of canonical repo names has changed to use plus (+) instead of tilde (~):

.../external/rules_jvm_external++maven+maven/io/kubernetes/client-java-api/26.0.0/processed_client-java-api-26.0.0.jar

This seems related to #3981, but the trigger here is not a nested jar. It is a repository path containing +.

Client Version
26.0.0

Kubernetes Version
1.35.1

Java Version
Java 17

To Reproduce
NA

Expected behavior
Prebuilt model map is not empty and contains pre-built kubernetes models from classpath.

KubeConfig
NA

Server (please complete the following information):

  • OS: -
  • Environment: -
  • Cloud: -

Additional context
NA

Activity

  1. laureanobrs commented on Apr 20, 2026

    @laureanobrs
    Author

    One possible minimal-delta fix could be to encode the + ahead of time:

    String jarFileName = URLDecoder.decode(packageURL.getFile().replace("+", "%2B"), StandardCharsets.UTF_8);

  2. brendandburns commented on Apr 25, 2026

    @brendandburns
    Contributor

    I'm trying to find the specification for a jar file reference, the best I have found is this:

    https://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html

    Which seems to indicate that the file is in fact a URL, which means that we should decode it, and the right solution would be for the + to be URL encoded before it is passed into the function.

    Where are you getting your paths with + from? can you send an example?

  3. laureanobrs commented on Apr 29, 2026

    @laureanobrs
    Author

    Hi Brendan, thanks for your reply. Here’s a minimal reproduction with Bazel:

    Bazel project Setup

    File .bazelversion

    8.5.0
    

    File MODULE.bazel

    module(
        version = "0.1.0",
    )
    bazel_dep(name = "rules_jvm_external", version = "6.10")
    maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
    maven.install(
        name = "maven",
        artifacts = [
            "io.kubernetes:client-java:26.0.0",
        ],
        repositories = [
            "https://repo1.maven.org/maven2",
        ],
    )
    use_repo(maven, "maven")
    

    File BUILD.bazel

    genrule(
        name = "show_client_java_api_jar",
        srcs = [
            "@maven//:io_kubernetes_client_java",
        ],
        outs = ["dummy.txt"],
        cmd = "echo just forcing download of libraries > $@",
    )
    

    Run bazel mod deps --lockfile_mode=update && bazel run @maven//:pin && bazel build //...

    Path containing the + symbol

    Run find bazel-out/ | grep "processed_client-java-26.0.0.jar"

    bazel-out/k8-fastbuild/bin/external/rules_jvm_external++maven+maven/v1/https/repo1.maven.org/maven2/io/kubernetes/client-java/26.0.0/processed_client-java-26.0.0.jar
    

    (Note the plus signs in rules_jvm_external++maven+maven.)
    That is the jar file that ModelMapper tries to load in the project I’m working on.

  4. brendandburns commented on Apr 30, 2026

    @brendandburns
    Contributor

    I guess, I'm wondering if the + should be encoded when the Jar URL is created. If the Java docs I cited above are correct, it seems that the text after "jar:" is a URL, and thus if the + is in the file name, it should be URL encoded before the URL is created.

    Again, not trying to pass the buck on fixing this, but trying to understand what the actual "right" answer is here.

  5. laureanobrs commented on Apr 30, 2026

    @laureanobrs
    Author

    It makes sense to clarify this.

    According to Java’s URLDecoder documentation:

    Utility class for HTML form decoding. This class contains static methods for decoding a String from the application/x-www-form-urlencoded MIME format.
    

    And Java’s URL documentation:

    The syntax of URL is defined by RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax, amended by RFC 2732: Format for Literal IPv6 Addresses in URLs.
    ...
    Note, the URI class does perform escaping of its component fields in certain circumstances.
    The URL class does not itself encode or decode any URL components according to the escaping mechanism defined in RFC2396.
    The URLEncoder and URLDecoder classes can also be used, but only for HTML form encoding, which is not the same as the encoding scheme defined in RFC2396.
    

    From that, I understand that:

    • In a URL path, + means a literal plus sign: RFC 3986
    • In application/x-www-form-urlencoded data, + means a space: WHATWG

    And since we’re talking about paths here, not HTML form data, I think URLDecoder may not be the right tool for this case.

    Also, there’s a bug in the OpenJDK bug system (closed as “Not an Issue”) that I think is related to this:
    https://bugs.openjdk.org/browse/JDK-8179507

  6. brendandburns commented on May 1, 2026

    @brendandburns
    Contributor

    @laureanobrs thanks for the additional details, I merged #4712 that should fix this. If this is important to you, please file a cherry-pick PR into the release branch and we can cut a new library version.

    If it's not important, we'll pick this up in the next major library release (roughly timed to k8s release cycles)

  7. laureanobrs commented on May 5, 2026

    @laureanobrs
    Author

    @brendandburns Thanks! I opened PR #4737 to cut a new release with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions