{"record":{"id":"96cd5146f18c4057","repo":"apache/flink","slug":"bad-syntax-for-classpath","errorCode":null,"errorMessage":"Bad syntax for classpath: {}","messagePattern":"Bad syntax for classpath: (.+?)","errorType":"validation","errorClass":"CliArgsException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/cli/ProgramOptions.java","lineNumber":91,"sourceCode":"        this.entryPointClass =\n                line.hasOption(CLASS_OPTION.getOpt())\n                        ? line.getOptionValue(CLASS_OPTION.getOpt())\n                        : null;\n\n        this.jarFilePath =\n                line.hasOption(JAR_OPTION.getOpt())\n                        ? line.getOptionValue(JAR_OPTION.getOpt())\n                        : null;\n\n        this.programArgs = extractProgramArgs(line);\n\n        List<URL> classpaths = new ArrayList<URL>();\n        if (line.hasOption(CLASSPATH_OPTION.getOpt())) {\n            for (String path : line.getOptionValues(CLASSPATH_OPTION.getOpt())) {\n                try {\n                    classpaths.add(new URL(path));\n                } catch (MalformedURLException e) {\n                    throw new CliArgsException(\"Bad syntax for classpath: \" + path);\n                }\n            }\n        }\n        this.classpaths = classpaths;\n\n        if (line.hasOption(PARALLELISM_OPTION.getOpt())) {\n            hasParallelismOpt = true;\n            String parString = line.getOptionValue(PARALLELISM_OPTION.getOpt());\n            try {\n                parallelism = Integer.parseInt(parString);\n                if (parallelism <= 0 && parallelism != ExecutionConfig.PARALLELISM_DEFAULT) {\n                    throw new NumberFormatException();\n                }\n            } catch (NumberFormatException e) {\n                throw new CliArgsException(\n                        \"The parallelism must be a positive number: \" + parString);\n            }\n        } else {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/cli/ProgramOptions.java#L73-L109","documentation":"Thrown by ProgramOptions constructor when parsing the --classpath (-c) option values. Each classpath entry is passed to `new URL(path)`, and if the path string is not a valid URL (missing protocol, malformed characters), MalformedURLException is caught and re-thrown as CliArgsException. Flink requires fully-qualified URL syntax for classpath entries (file://, http://, etc.).","triggerScenarios":"Passing a bare filesystem path like `/opt/libs/mylib.jar` instead of `file:///opt/libs/mylib.jar`; using a relative path; malformed URL with illegal characters or unencoded spaces.","commonSituations":"User accustomed to colon-separated classpaths (like Java's -cp) passes `lib/a.jar:lib/b.jar` which is not valid URL syntax; spaces in paths that aren't URL-encoded; mixing forward/backward slashes on Windows.","solutions":["Prefix filesystem paths with file:// protocol, e.g. `-c file:///opt/libs/mylib.jar`","Use absolute paths with proper URL encoding (replace spaces with %20)","Pass each classpath entry as a separate -c argument"],"exampleFix":"// before\nflink run -c /opt/libs/mylib.jar ./job.jar\n\n// after\nflink run -c file:///opt/libs/mylib.jar ./job.jar","handlingStrategy":"validation","validationCode":"for (String path : classpathEntries) {\n    try {\n        new URL(path);\n    } catch (MalformedURLException e) {\n        // auto-fix bare paths\n        String fixed = path.startsWith(\"file:\") ? path : \"file://\" + new File(path).getAbsolutePath();\n        urls.add(new URL(fixed));\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always prefix filesystem paths with file:// in -c/--classpath arguments","Use absolute paths to avoid resolution ambiguity","URL-encode spaces and special characters in paths"],"tags":["cli","classpath","user-input","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}