{"record":{"id":"04c5d19b69da10e6","repo":"apache/dolphinscheduler","slug":"generate-excel-error","errorCode":null,"errorMessage":"generate excel error","messagePattern":"generate excel error","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":129,"sourceCode":"                    } else {\n                        String cellValue = String.valueOf(values[j]);\n                        int maxLen = SpreadsheetVersion.EXCEL2007.getMaxTextLength();\n                        if (cellValue.length() > maxLen) {\n                            cellValue = cellValue.substring(0, maxLen - 67) + \"...(truncated)\";\n                        }\n                        cell1.setCellValue(cellValue);\n                    }\n                }\n            }\n\n            for (int i = 0; i < headerList.size(); i++) {\n                sheet.setColumnWidth(i, headerList.get(i).length() * 800);\n            }\n\n            // setting file output\n            wb.write(fos);\n        } catch (Exception e) {\n            throw new AlertEmailException(\"generate excel error\", e);\n        }\n    }\n\n}\n","sourceCodeStart":111,"sourceCodeEnd":134,"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#L111-L134","documentation":"The final stage of genExcelFile wraps any exception thrown while building the workbook or writing it to the FileOutputStream (wb.write(fos)) in AlertEmailException('generate excel error', e). It is a generic wrapper: the root cause (POI error, IO error) is in the chained exception.","triggerScenarios":"wb.write(fos) fails: the target path exists as a directory, disk is full, the FileOutputStream cannot be opened, or POI throws while processing malformed rows/headers (e.g. null header values).","commonSituations":"xlsFilePath points to an existing directory so the file cannot be opened for writing; disk full on the alert server; content contains null keys producing null headers.","solutions":["Inspect the chained cause exception in the logs for the true root cause.","Ensure xlsFilePath is a writable file path, not a directory, and the disk has free space.","Upgrade/verify Apache POI dependencies are consistent on the classpath.","Sanitize alert content so header keys are never null."],"exampleFix":"// before\nFileOutputStream fos = new FileOutputStream(xlsFilePath + title + \".xlsx\");\n// after\nFile outFile = new File(xlsFilePath, title + \".xlsx\");\nif (outFile.isDirectory()) { throw new AlertEmailException(\"target is a directory: \" + outFile); }\nFileOutputStream fos = new FileOutputStream(outFile);","handlingStrategy":"try-catch","validationCode":"File out = new File(xlsFilePath, title + \".xlsx\");\nif (out.isDirectory() || !out.getParentFile().canWrite()) { throw new IllegalStateException(\"bad excel target: \" + out); }","typeGuard":null,"tryCatchPattern":"try { ExcelUtils.genExcelFile(content, title, xlsFilePath); } catch (AlertEmailException e) { log.error(\"excel write failed: {}\", e.getCause(), e); }","preventionTips":["Always inspect the chained cause of this generic wrapper","Ensure the target path is a file path, not a directory","Keep POI library versions consistent; monitor disk space"],"tags":["io","poi","excel","alert-email"],"backgroundTag":"file-write-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"}