{"record":{"id":"93ce17c1f80c0ede","repo":"iflytek/astron-agent","slug":"workflow-artifact-file-too-large","errorCode":"WORKFLOW_ARTIFACT_FILE_TOO_LARGE","errorMessage":"WORKFLOW_ARTIFACT_FILE_TOO_LARGE","messagePattern":"WORKFLOW_ARTIFACT_FILE_TOO_LARGE","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java","lineNumber":225,"sourceCode":"            }\n        }\n    }\n\n    private Path copyToTemporaryFile(MultipartFile file) throws IOException {\n        Path temporaryFile = Files.createTempFile(\"astron-workflow-artifact-\", \".ooxml\");\n        boolean completed = false;\n        try (InputStream input = file.getInputStream();\n                OutputStream output = Files.newOutputStream(\n                        temporaryFile,\n                        StandardOpenOption.WRITE,\n                        StandardOpenOption.TRUNCATE_EXISTING)) {\n            byte[] buffer = new byte[COPY_BUFFER_SIZE];\n            long copied = 0;\n            int read;\n            while ((read = input.read(buffer)) != -1) {\n                copied += read;\n                if (copied > properties.getArtifactMaxFileSize().toBytes()) {\n                    throw new BusinessException(ResponseEnum.WORKFLOW_ARTIFACT_FILE_TOO_LARGE);\n                }\n                output.write(buffer, 0, read);\n            }\n            completed = true;\n            return temporaryFile;\n        } finally {\n            if (!completed) {\n                Files.deleteIfExists(temporaryFile);\n            }\n        }\n    }\n\n    /**\n     * Reads every archive entry through POI's zip-bomb-aware stream before OPC parsing. POI only\n     * exposes JVM-global limits, so per-upload absolute limits are enforced here as well to avoid\n     * changing the behavior of unrelated Excel import paths in the same application.\n     */\n    void validateOoxmlResourceLimits(Path file) throws IOException {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java#L207-L243","documentation":"copyToTemporaryFile enforces the configured per-file size limit (properties.getArtifactMaxFileSize) byte-by-byte while streaming the MultipartFile to a temp file before OOXML parsing. If the copied byte count exceeds the limit it throws WORKFLOW_ARTIFACT_FILE_TOO_LARGE. This second check exists because the earlier file.getSize() check can be bypassed or diverge for certain multipart implementations.","triggerScenarios":"validate() (via validateOoxmlContainer) called with an Office document whose streamed content exceeds artifactMaxFileSize even though file.getSize() passed — e.g. size reported incorrectly by the multipart layer, or the limit lowered by config between the size check and the copy.","commonSituations":"artifactMaxFileSize configured below actual large xlsx/docx files; multipart parsers that misreport size; requests that passed a proxy-level limit but not the application-level one.","solutions":["Reduce the file size or split the document; strip large embedded media/images from the Office file.","Raise SkillSandboxArtifactProperties.artifactMaxFileSize to accommodate legitimate documents (also ensure Spring's spring.servlet.multipart.max-file-size and any proxy body limits are raised consistently).","Verify the reported size: compare file.getSize() with actual bytes to catch multipart-layer misreporting."],"exampleFix":"// before\nartifact.max-file-size=10MB\n// after\nartifact.max-file-size=50MB\n# plus spring.servlet.multipart.max-file-size=50MB","handlingStrategy":"validation","validationCode":"long maxBytes = properties.getArtifactMaxFileSize().toBytes();\nif (file.getSize() <= 0 || file.getSize() > maxBytes) { /* reject before validate() */ }\n// and client-side: check file.size before upload","typeGuard":null,"tryCatchPattern":"try { validator.validate(file); } catch (BusinessException e) { /* map to HTTP 413 with the configured limit in the message */ }","preventionTips":["Check file size in the browser/client before upload and show the limit in the UI.","Keep spring.servlet.multipart.max-file-size, proxy body limits, and artifactMaxFileSize aligned.","Strip large embedded media from Office documents to shrink them."],"tags":["file-upload","file-size","limit","spring"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}