{"record":{"id":"5ac21823c25f2bba","repo":"apache/dolphinscheduler","slug":"cancel-paragraph-error","errorCode":null,"errorMessage":"cancel paragraph error","messagePattern":"cancel paragraph error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java","lineNumber":246,"sourceCode":"    @Override\n    public void cancelApplication() throws TaskException {\n        final String restEndpoint = this.zeppelinParameters.getRestEndpoint();\n        final String noteId = this.zeppelinParameters.getNoteId();\n        final String paragraphId = this.zeppelinParameters.getParagraphId();\n        if (paragraphId == null) {\n            log.info(\"trying terminate zeppelin task, taskId: {}, noteId: {}\",\n                    this.taskExecutionContext.getTaskInstanceId(), noteId);\n            Unirest.config().defaultBaseUrl(restEndpoint + \"/api\");\n            Unirest.delete(\"/notebook/job/{noteId}\").routeParam(\"noteId\", noteId).asJson();\n            log.info(\"zeppelin task terminated, taskId: {}, noteId: {}\", this.taskExecutionContext.getTaskInstanceId(),\n                    noteId);\n        } else {\n            log.info(\"trying terminate zeppelin task, taskId: {}, noteId: {}, paragraphId: {}\",\n                    this.taskExecutionContext.getTaskInstanceId(), noteId, paragraphId);\n            try {\n                this.zClient.cancelParagraph(noteId, paragraphId);\n            } catch (Exception e) {\n                throw new TaskException(\"cancel paragraph error\", e);\n            }\n            log.info(\"zeppelin task terminated, taskId: {}, noteId: {}, paragraphId: {}\",\n                    this.taskExecutionContext.getTaskInstanceId(), noteId, paragraphId);\n        }\n\n    }\n\n    @Override\n    public List<String> getApplicationIds() throws TaskException {\n        return Collections.emptyList();\n    }\n\n    public void addDefaultOutput(String response) {\n        // put response in output\n        Property outputProperty = new Property();\n        outputProperty.setProp(String.format(\"%s.%s\", taskExecutionContext.getTaskName(), \"result\"));\n        outputProperty.setDirect(Direct.OUT);\n        outputProperty.setType(DataType.VARCHAR);","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java#L228-L264","documentation":"ZeppelinTask.cancelApplication wraps any exception from zClient.cancelParagraph(noteId, paragraphId) into a TaskException with the message 'cancel paragraph error'. It means the attempt to terminate a running Zeppelin paragraph via the Zeppelin client API failed. The underlying cause (network problem, invalid note/paragraph id, Zeppelin server down) is attached as the cause.","triggerScenarios":"Calling cancelApplication (task kill/cancel from DolphinScheduler) when the Zeppelin client throws while cancelling the paragraph: Zeppelin server unreachable, noteId/paragraphId invalid or already finished, or an authentication/session error in ZeppelinClient.","commonSituations":"Killing a running Zeppelin task whose Zeppelin server has been restarted or is down; stale paragraphId from a prior run; Zeppelin returning an error for an already-completed paragraph; network/firewall issues between the worker and Zeppelin.","solutions":["Verify the Zeppelin server URL and credentials in the task/plugin configuration are correct and the server is reachable (curl the REST endpoint).","Check the wrapped cause in the TaskException stack trace for the real Zeppelin client error.","Confirm noteId and paragraphId were captured from the task output correctly; re-run the task to get fresh IDs if the paragraph already finished.","Retry the cancel; if the paragraph already completed, treat the task as finished instead of failed."],"exampleFix":"// before\ntry {\n    this.zClient.cancelParagraph(noteId, paragraphId);\n} catch (Exception e) {\n    throw new TaskException(\"cancel paragraph error\", e);\n}\n// after\ntry {\n    this.zClient.cancelParagraph(noteId, paragraphId);\n} catch (Exception e) {\n    log.warn(\"Cancel paragraph failed, noteId: {}, paragraphId: {}\", noteId, paragraphId, e);\n    throw new TaskException(\"cancel paragraph error, noteId: \" + noteId + \", paragraphId: \" + paragraphId, e);\n}","handlingStrategy":"try-catch","validationCode":"// before cancelling, verify the paragraph is still running\nString status = zeppelinClient.getParagraphStatus(noteId, paragraphId);\nif (!\"RUNNING\".equals(status)) { log.info(\"paragraph {} already finished\", paragraphId); return; }\n// and verify the server is reachable\n// new java.net.URL(zeppelinUrl).openConnection().connect();","typeGuard":null,"tryCatchPattern":"try {\n    task.cancel();\n} catch (TaskException e) {\n    log.error(\"Zeppelin cancel failed: {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage(), e);\n    // decide whether to rethrow based on whether the task is still running\n}","preventionTips":["Health-check the Zeppelin server before submitting tasks.","Persist noteId/paragraphId from task output and reuse them for cancel.","Treat 'paragraph already completed' cancels as success, not failure.","Set reasonable Zeppelin client timeouts."],"tags":["zeppelin","task-cancel","network"],"backgroundTag":"api-request-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}