{"record":{"id":"b82187d7c0bdc23d","repo":"apache/flink","slug":"missing-jobid-b82187","errorCode":null,"errorMessage":"Missing JobId","messagePattern":"Missing JobId","errorType":"validation","errorClass":"CliArgsException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java","lineNumber":696,"sourceCode":"            return SavepointRestoreSettings.forPath(\n                    savepointPath, allowNonRestoredState, recoveryClaimMode);\n        } else {\n            return SavepointRestoreSettings.none();\n        }\n    }\n\n    // --------------------------------------------------------------------------------------------\n    //  Line Parsing\n    // --------------------------------------------------------------------------------------------\n\n    public static CommandLine parse(Options options, String[] args, boolean stopAtNonOptions)\n            throws CliArgsException {\n        final DefaultParser parser = new DefaultParser();\n\n        try {\n            return parser.parse(options, args, stopAtNonOptions);\n        } catch (ParseException e) {\n            throw new CliArgsException(e.getMessage());\n        }\n    }\n\n    /**\n     * Merges the given {@link Options} into a new Options object.\n     *\n     * @param optionsA options to merge, can be null if none\n     * @param optionsB options to merge, can be null if none\n     * @return\n     */\n    public static Options mergeOptions(@Nullable Options optionsA, @Nullable Options optionsB) {\n        final Options resultOptions = new Options();\n        if (optionsA != null) {\n            for (Option option : optionsA.getOptions()) {\n                resultOptions.addOption(option);\n            }\n        }\n","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontendParser.java#L678-L714","documentation":"Thrown by CliFrontend.parseJobId (CliFrontend.java:1161) when the jobId string argument is null for commands that require a job ID (cancel, stop, savepoint dispose, trigger checkpoint). The parse() method at CliFrontendParser.java:696 wraps commons-cli ParseException messages into CliArgsException, but the specific 'Missing JobId' message originates from parseJobId checking for a null jobIdString. Flink needs a valid JobID hex string to target the specific job for the operation.","triggerScenarios":"Running `flink cancel` or `flink stop` with no positional jobId argument; providing the jobId via the wrong flag so the positional parser receives nothing; the jobId positional argument is consumed by an earlier option that stole it.","commonSituations":"User runs `flink cancel` expecting a prompt but gets an immediate error; user passes --jobId (wrong flag) instead of a bare positional argument; shell scripting that conditionally appends the jobId but the variable evaluates to empty.","solutions":["Provide the JobID as a positional argument: `flink cancel <32-hex-char-jobId>`","Get the JobID from `flink list` output first, then pass it to cancel/stop","In scripts, validate the jobId variable is non-empty before invoking the command"],"exampleFix":"# before\nflink cancel\n\n# after\nflink cancel a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4","handlingStrategy":"validation","validationCode":"if (jobIdString == null || jobIdString.isBlank()) {\n    throw new IllegalArgumentException(\n        \"JobId is required. Run 'flink list' to find the job ID.\");\n}\nJobID jobId = JobID.fromHexString(jobIdString); // validate format","typeGuard":null,"tryCatchPattern":"try {\n    JobID jobId = cliFrontend.parseJobId(jobIdArg);\n} catch (CliArgsException e) {\n    if (e.getMessage().contains(\"Missing JobId\")) {\n        System.err.println(\"Usage: flink cancel <jobId>\");\n    }\n    throw e;\n}","preventionTips":["In scripts, check that the jobId variable is non-empty before passing it","Run 'flink list' first to obtain valid job IDs","Pass the jobId as a positional argument, not a flag"],"tags":["cli","job-management","user-input"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}