{"record":{"id":"b9c2decb06aeb005","repo":"apache/dolphinscheduler","slug":"itemslist-is-null","errorCode":null,"errorMessage":"itemsList is null","messagePattern":"itemsList is null","errorType":"exception","errorClass":"AlertEmailException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java","lineNumber":67,"sourceCode":"    /**\n     * generate excel file\n     *\n     * @param content the content\n     * @param title the title\n     * @param xlsFilePath the xls path\n     */\n    static void genExcelFile(String content, String title, String xlsFilePath) {\n        File file = new File(xlsFilePath);\n        if (!file.exists() && !file.mkdirs()) {\n            log.error(\"Create xlsx directory error, path:{}\", xlsFilePath);\n            throw new AlertEmailException(\"Create xlsx directory error\");\n        }\n\n        List<LinkedHashMap> itemsList = JSONUtils.toList(content, LinkedHashMap.class);\n\n        if (CollectionUtils.isEmpty(itemsList)) {\n            log.error(\"itemsList is null\");\n            throw new AlertEmailException(\"itemsList is null\");\n        }\n\n        LinkedHashMap<String, Object> headerMap = itemsList.get(0);\n\n        List<String> headerList = new ArrayList<>();\n\n        for (Map.Entry<String, Object> en : headerMap.entrySet()) {\n            headerList.add(en.getKey());\n        }\n        try (\n                SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW);\n                FileOutputStream fos = new FileOutputStream(String.format(\"%s/%s.xlsx\", xlsFilePath, title))) {\n            // declare a workbook\n            // generate a table\n            Sheet sheet = wb.createSheet();\n            Row row = sheet.createRow(0);\n            // set the height of the first line\n            row.setHeight((short) 500);","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java#L49-L85","documentation":"After parsing the alert content JSON with JSONUtils.toList, genExcelFile checks whether the resulting list is empty and throws AlertEmailException('itemsList is null') when it is. The Excel attachment cannot be built without at least one row of data.","triggerScenarios":"The alert 'content' passed to genExcelFile is null, not valid JSON, an empty JSON array, or JSON that deserializes to an empty list (e.g. empty alert result sets with empty showType data).","commonSituations":"Workflow finished with no result rows so the alert content is '[]' or empty string; upstream task produced malformed output that JSONUtils.toList silently converts to null; showType configured as TABLE but no data available.","solutions":["Guard at the alert producer: only send email alerts with TABLE showType when there is result data.","Validate that the content string is a non-empty JSON array of objects before configuring the email alert.","Skip Excel attachment generation when the alert result set is empty."],"exampleFix":"// before\nList<LinkedHashMap> itemsList = JSONUtils.toList(content, LinkedHashMap.class);\n// after\nif (content == null || content.trim().isEmpty()) { return; } // skip empty alerts upstream\nList<LinkedHashMap> itemsList = JSONUtils.toList(content, LinkedHashMap.class);","handlingStrategy":"type-guard","validationCode":"if (content == null || content.trim().isEmpty() || \"[]\".equals(content.trim())) { skipEmailAttachment(); }","typeGuard":"boolean hasRows(String json) { List<?> l = JSONUtils.toList(json, Object.class); return l != null && !l.isEmpty(); }","tryCatchPattern":"try { ExcelUtils.genExcelFile(content, title, path); } catch (AlertEmailException e) { log.warn(\"empty/invalid alert content skipped\", e); }","preventionTips":["Only configure TABLE showType alerts for tasks that always return data","Short-circuit empty alert payloads before calling genExcelFile","Validate alert JSON content in custom task implementations"],"tags":["json","alert-email","empty-data"],"backgroundTag":"empty-result-set","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"}