{"record":{"id":"fdc3fc0cd562ed77","repo":"apache/flink","slug":"jobstatus-jobstatus-does-not-have-a-correspondin","errorCode":null,"errorMessage":"JobStatus {jobStatus} does not have a corresponding ApplicationState.","messagePattern":"JobStatus (.+?) does not have a corresponding ApplicationState\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/ApplicationState.java","lineNumber":84,"sourceCode":"\n    private static final Map<JobStatus, ApplicationState> JOB_STATUS_APPLICATION_STATE_MAP =\n            new HashMap<>();\n\n    static {\n        // only globally terminal JobStatus can have a corresponding ApplicationState\n        JOB_STATUS_APPLICATION_STATE_MAP.put(JobStatus.FAILED, ApplicationState.FAILED);\n        JOB_STATUS_APPLICATION_STATE_MAP.put(JobStatus.CANCELED, ApplicationState.CANCELED);\n        JOB_STATUS_APPLICATION_STATE_MAP.put(JobStatus.FINISHED, ApplicationState.FINISHED);\n    }\n\n    /**\n     * Derives the ApplicationState that corresponds to the given JobStatus. This method only\n     * accepts globally terminal JobStatus. If the job status is not globally terminal, this method\n     * throws an IllegalArgumentException.\n     */\n    public static ApplicationState fromJobStatus(JobStatus jobStatus) {\n        if (!JOB_STATUS_APPLICATION_STATE_MAP.containsKey(jobStatus)) {\n            throw new IllegalArgumentException(\n                    \"JobStatus \" + jobStatus + \" does not have a corresponding ApplicationState.\");\n        }\n\n        return JOB_STATUS_APPLICATION_STATE_MAP.get(jobStatus);\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/ApplicationState.java#L66-L91","documentation":"Thrown by ApplicationState.fromJobStatus when the given JobStatus is not one of the globally terminal states mapped to an ApplicationState (FINISHED, CANCELED, FAILED). The framework maps only terminal job outcomes to application lifecycle states; non-terminal states (CREATED, RUNNING, RESTARTING, FAILING, CANCELLING, RECONCILING, SUSPENDED, INITIALIZING) and UNKNOWN have no ApplicationState equivalent, so the call is a programming error.","triggerScenarios":"Calling ApplicationState.fromJobStatus with a still-running or non-terminal JobStatus; polling a job and feeding its current status into fromJobStatus without checking isGloballyTerminalState() first.","commonSituations":"Application-mode deployments that translate JobStatus to ApplicationState for cluster shutdown logic; code that assumed every JobStatus maps cleanly; tests passing arbitrary enum values.","solutions":["Check jobStatus.isGloballyTerminalState() before calling fromJobStatus, and skip/await otherwise.","Restrict upstream logic to only the three terminal states the map supports.","If you need to handle non-terminal states, branch on them explicitly rather than routing through fromJobStatus."],"exampleFix":"// before\nApplicationState s = ApplicationState.fromJobStatus(jobStatus);\n// after\nif (!jobStatus.isGloballyTerminalState()) {\n    // job still running; do not derive an ApplicationState yet\n    return;\n}\nApplicationState s = ApplicationState.fromJobStatus(jobStatus);","handlingStrategy":"validation","validationCode":"if (jobStatus == null || !jobStatus.isGloballyTerminalState()) {\n    // not convertible; await or skip\n    return;\n}\nApplicationState s = ApplicationState.fromJobStatus(jobStatus);","typeGuard":"public static boolean isConvertible(JobStatus js) {\n    return js != null && js.isGloballyTerminalState();\n}","tryCatchPattern":null,"preventionTips":["Always check isGloballyTerminalState() before fromJobStatus.","Branch non-terminal states explicitly in shutdown logic.","Unit-test with all JobStatus values to confirm only terminals pass."],"tags":["application-state","job-status","terminal","state-machine"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}