{"record":{"id":"ca03a312dcdde62b","repo":"apache/flink","slug":"jar-file-path-invalid","errorCode":null,"errorMessage":"JAR file path invalid","messagePattern":"JAR file path invalid","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/JarUtils.java","lineNumber":74,"sourceCode":"                    \"Error while opening jar file '\" + jarFile.getAbsolutePath() + '\\'', e);\n        }\n    }\n\n    public static List<URL> getJarFiles(final String[] jars) {\n        if (jars == null) {\n            return Collections.emptyList();\n        }\n\n        return Arrays.stream(jars)\n                .map(\n                        jarPath -> {\n                            try {\n                                final URL fileURL =\n                                        new File(jarPath).getAbsoluteFile().toURI().toURL();\n                                JarUtils.checkJarFile(fileURL);\n                                return fileURL;\n                            } catch (MalformedURLException e) {\n                                throw new IllegalArgumentException(\"JAR file path invalid\", e);\n                            } catch (IOException e) {\n                                throw new RuntimeException(\"Problem with jar file \" + jarPath, e);\n                            }\n                        })\n                .collect(Collectors.toList());\n    }\n}\n","sourceCodeStart":56,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/JarUtils.java#L56-L82","documentation":"In JarUtils.getJarFiles, each raw path string is converted with new File(jarPath).getAbsoluteFile().toURI().toURL(). If that throws MalformedURLException, this IllegalArgumentException ('JAR file path invalid') wraps it. With File-based conversion this is rare, but it fires for degenerate path inputs that cannot form a URL (e.g. null-like or malformed path fragments after the URL encoding step).","triggerScenarios":"Calling JarUtils.getJarFiles(String[]) with a path string that File.toURI().toURL() rejects — essentially only reachable with malformed/URI-illegal inputs, since File-based URL construction almost never throws MalformedURLException; treat it as a defensive guard on untrusted path strings.","commonSituations":"Programmatic callers passing unvalidated user input (e.g. parsed CLI args or config values) into getJarFiles; a path containing characters that break URI syntax; historically, code that passed URL-ish strings ('http://...') where a filesystem path was expected.","solutions":["Pass plain filesystem paths (absolute or relative) to getJarFiles, not URLs or URI fragments.","Validate inputs before the call: reject null/empty strings and strings with illegal path characters.","Log the offending jarPath when catching to identify which entry in the array failed.","Prefer new File(jarPath).toURI().toURL() yourself if you need URL semantics, so failure points are explicit."],"exampleFix":"// before\nList<URL> jars = JarUtils.getJarFiles(new String[] {\"file:/opt/lib/a b.jar\"});\n\n// after\nList<URL> jars = JarUtils.getJarFiles(new String[] {\"/opt/lib/a b.jar\"}); // plain path, File handles encoding","handlingStrategy":"validation","validationCode":"for (String jar : jars) {\n    if (jar == null || jar.isBlank()) {\n        throw new IllegalArgumentException(\"jar path must be a non-empty filesystem path\");\n    }\n}\nList<URL> urls = JarUtils.getJarFiles(jars);","typeGuard":null,"tryCatchPattern":"try {\n    return JarUtils.getJarFiles(jars);\n} catch (IllegalArgumentException e) {\n    // identify and report the offending path element\n}","preventionTips":["Pass plain filesystem paths, not URLs, to getJarFiles","Sanitize untrusted path inputs before conversion","Reject null/blank entries in path arrays at config-parse time"],"tags":["jar","url","validation","classpath"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}