{"record":{"id":"292e5b3aea9f415a","repo":"apple/pkl","slug":"invalid-jar-uri-missing","errorCode":null,"errorMessage":"Invalid `jar:` URI (missing `!`): ","messagePattern":"Invalid `jar:` URI \\(missing `!`\\): ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/IoUtils.java","lineNumber":886,"sourceCode":"      } else {\n        sb.append(character);\n      }\n    }\n    return sb.toString();\n  }\n\n  /** Returns a path string that uses unix-like path separators. */\n  public static String toNormalizedPathString(Path path) {\n    if (isWindows()) {\n      return path.toString().replace(\"\\\\\", \"/\");\n    }\n    return path.toString();\n  }\n\n  private static int getExclamationMarkIndex(String jarUri) {\n    var index = jarUri.indexOf('!');\n    if (index == -1) {\n      throw new IllegalArgumentException(\"Invalid `jar:` URI (missing `!`): \" + jarUri);\n    }\n    return index;\n  }\n\n  public static void validateFileUri(URI uri) throws URISyntaxException {\n    if (!uri.getSchemeSpecificPart().startsWith(\"/\")) {\n      throw new URISyntaxException(uri.toString(), ErrorMessages.create(\"invalidOpaqueFileUri\"));\n    }\n  }\n\n  public static void validateRewriteRule(URI rewrite) {\n    if (!Objects.equals(rewrite.getScheme(), \"http\")\n        && !Objects.equals(rewrite.getScheme(), \"https\")) {\n      throw new IllegalArgumentException(\n          \"Rewrite rule must start with 'http://' or 'https://', but was '%s'\".formatted(rewrite));\n    }\n\n    if (!rewrite.toString().endsWith(\"/\")) {","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java#L868-L904","documentation":"Helper getExclamationMarkIndex parses jar: URIs of the form jar:<inner-uri>!/entry. It throws IllegalArgumentException when the string contains no '!' separator, meaning no nested entry is specified, which Pkl cannot treat as a valid jar URI.","triggerScenarios":"Calling IoUtils jar-URI utilities (extracting the inner URI or entry path) with a string like 'file:/lib.jar' that lacks the '!/path' suffix.","commonSituations":"Passing a plain JAR file path or inner URI to code expecting jar:<base>!<entry>, e.g. when resolving resources inside jars on the classpath.","solutions":["Append the '!/<entry>' suffix naming the resource inside the jar","Strip the 'jar:' scheme first if you meant to handle the inner URI instead","Check with indexOf('!') before invoking the jar-parsing helper"],"exampleFix":"// before\nString inner = IoUtils.extractJarPath(\"file:/lib/app.jar\");\n// after\nString inner = IoUtils.extractJarPath(\"jar:file:/lib/app.jar!/resources/module.pkl\");","handlingStrategy":"validation","validationCode":"if (!jarUri.startsWith(\"jar:\") || !jarUri.contains(\"!\")) throw new IllegalArgumentException(\"expected jar:<uri>!/<entry>\");","typeGuard":"function isJarEntryUri(s) { return /^jar:.+!\\/.+/.test(s); }","tryCatchPattern":"try { parseJarUri(jarUri) } catch (IllegalArgumentException e) { /* fall back to treating as plain file */ }","preventionTips":["Always include the !/<entry> suffix when building jar: URIs","Validate jar URI shape before passing to IoUtils helpers","Build jar URIs programmatically: \"jar:\" + innerUri + \"!/\" + entryPath"],"tags":["uri","jar","argument-validation"],"backgroundTag":"invalid-url-format","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}