{"record":{"id":"ee0f169cbae7b466","repo":"jeecgboot/JeecgBoot","slug":"message-ee0f16","errorCode":null,"errorMessage":"添加图片异常: {message}","messagePattern":"添加图片异常: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/wordtpl/utils/WordUtil.java","lineNumber":803,"sourceCode":"                    case \"center\":\n                        paragraph.setAlignment(ParagraphAlignment.CENTER);\n                        break;\n                    case \"right\":\n                        paragraph.setAlignment(ParagraphAlignment.RIGHT);\n                        break;\n                    case \"alignment\":\n                        paragraph.setAlignment(ParagraphAlignment.BOTH);\n                        break;\n                    default:\n                        paragraph.setAlignment(ParagraphAlignment.LEFT);\n                        break;\n                }\n            } else {\n                paragraph.setAlignment(ParagraphAlignment.LEFT);\n            }\n        } catch (Exception e) {\n            log.error(\"添加图片异常\", e);\n            throw new RuntimeException(\"添加图片异常: \" + e.getMessage(), e);\n        } finally {\n            if (null != in) {\n                try {\n                    in.close();\n                } catch (Exception e) {\n                    // ignore\n                    log.error(\"关闭图片流异常\", e);\n                }\n            }\n        }\n    }\n\n    /**\n     * 添加图片\n     *\n     * @param imageData 图片流\n     * @param doc   文档对象\n     * @param run   文档运行对象","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/wordtpl/utils/WordUtil.java#L785-L821","documentation":"WordUtil.addImage() inserts an image (web-downloaded or local) into an XWPFParagraph via POI. The outer try wraps ANY exception (fetch failure, POI addPicture error, missing width/height) as a RuntimeException with the cause message; a finally block closes the input stream.","triggerScenarios":"Remote image 404/timeout; SsrfFileTypeFilter rejects the URL (loopback/link-local); local path rejected by the traversal guard (error 129); width/height fields missing or non-numeric; unsupported picture format for addPicture.","commonSituations":"Broken/expired image URL; missing width/height in the content JSON; non-PNG/JPEG bytes passed as PNG; permission reading the local file.","solutions":["Read the cause message in '添加图片异常'.","Verify the image URL resolves and passes SSRF checks, or the local path is inside the upload dir.","Ensure width and height are present and positive in the content JSON.","Confirm the byte stream matches the picture type POI expects."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate image content JSON before insertion\nString value = content.getString(\"value\");\nif (oConvertUtils.isEmpty(value)) { throw new IllegalArgumentException(\"图片地址为空\"); }\nif (!content.containsKey(\"width\") || !content.containsKey(\"height\")) {\n    throw new IllegalArgumentException(\"缺少 width/height\");\n}","typeGuard":null,"tryCatchPattern":"try { WordUtil.addImage(paragraph, content); }\ncatch (RuntimeException e) {\n    log.error(\"插入图片失败, value={}\", content.getString(\"value\"), e);\n    // continue rendering without the image rather than failing the whole doc\n}","preventionTips":["Require width/height in the content schema.","Pre-validate remote URLs with the SSRF filter and local paths with the traversal guard.","Skip-and-log broken images instead of aborting the whole document."],"tags":["word","image","poi","ssrf","io"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}