{"record":{"id":"9963fdf2c2c3f3c8","repo":"apache/flink","slug":"no-valid-command-line-found","errorCode":null,"errorMessage":"No valid command-line found.","messagePattern":"No valid command-line found\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java","lineNumber":1463,"sourceCode":"    //  Custom command-line\n    // --------------------------------------------------------------------------------------------\n\n    /**\n     * Gets the custom command-line for the arguments.\n     *\n     * @param commandLine The input to the command-line.\n     * @return custom command-line which is active (may only be one at a time)\n     */\n    public CustomCommandLine validateAndGetActiveCommandLine(CommandLine commandLine) {\n        LOG.debug(\"Custom commandlines: {}\", customCommandLines);\n        for (CustomCommandLine cli : customCommandLines) {\n            LOG.debug(\n                    \"Checking custom commandline {}, isActive: {}\", cli, cli.isActive(commandLine));\n            if (cli.isActive(commandLine)) {\n                return cli;\n            }\n        }\n        throw new IllegalStateException(\"No valid command-line found.\");\n    }\n\n    /**\n     * Loads a class from the classpath that implements the CustomCommandLine interface.\n     *\n     * @param className The fully-qualified class name to load.\n     * @param params The constructor parameters\n     */\n    private static CustomCommandLine loadCustomCommandLine(String className, Object... params)\n            throws Exception {\n\n        Class<? extends CustomCommandLine> customCliClass =\n                Class.forName(className).asSubclass(CustomCommandLine.class);\n\n        // construct class types from the parameters\n        Class<?>[] types = new Class<?>[params.length];\n        for (int i = 0; i < params.length; i++) {\n            checkNotNull(params[i], \"Parameters for custom command-lines may not be null.\");","sourceCodeStart":1445,"sourceCodeEnd":1481,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java#L1445-L1481","documentation":"Thrown by CliFrontend.validateAndGetActiveCommandLine when none of the registered CustomCommandLine implementations (DefaultCLI, YarnSessionCli, KubernetesSessionCli, etc.) report isActive(commandLine) as true for the parsed arguments. Each custom CLI checks whether its specific options (e.g., -m for standalone, -yarn for YARN, -Dkubernetes.* for K8s) are present and consistent. If none match, Flink cannot determine which deployment backend to use. It is an IllegalStateException (unchecked).","triggerScenarios":"Passing conflicting or incomplete options that no single custom CLI recognizes as a valid active configuration; mixing options from different deployment backends (e.g., partial YARN + partial Kubernetes flags); running with a custom CLI plugin that was not loaded via service discovery.","commonSituations":"User provides -m with a value but also sets -Dkubernetes.cluster-id, causing both K8s and standalone CLIs to consider themselves non-active due to ambiguity; the flink-dist is missing the YARN or K8s connector jars from its lib/ directory, so the respective custom CLIs are never registered.","solutions":["Use -m/--target to specify the deployment target explicitly (e.g., -m yarn, -m kubernetes-session, -m <host>:<port>)","Ensure the appropriate connector jars (flink-yarn, flink-kubernetes) are in FLINK_HOME/lib or on the classpath so the corresponding CustomCommandLine implementations are discoverable","Avoid mixing deployment-specific options from different backends in the same command"],"exampleFix":"# before (ambiguous, no CLI activates)\nflink run -Dkubernetes.cluster-id=my-cluster -m yarn-session ./job.jar\n\n# after (pick one backend)\nflink run -m kubernetes-session -Dkubernetes.cluster-id=my-cluster ./job.jar","handlingStrategy":"validation","validationCode":"// Before deploying, verify at least one custom CLI will activate:\nboolean anyActive = customCommandLines.stream().anyMatch(cli -> cli.isActive(commandLine));\nif (!anyActive) {\n    throw new IllegalArgumentException(\n        \"No deployment backend matched. Set -m/--target and avoid mixing backend options.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    CustomCommandLine active = cliFrontend.validateAndGetActiveCommandLine(commandLine);\n} catch (IllegalStateException e) {\n    System.err.println(\"No deployment CLI activated. Check -m/--target and connector JARs.\");\n    throw e;\n}","preventionTips":["Always specify -m/--target to force one backend's CLI to activate","Keep only one deployment connector (YARN OR Kubernetes) on the classpath at a time if unsure","Avoid mixing deployment-specific flags from different backends"],"tags":["cli","deployment","configuration","startup"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}