{"record":{"id":"860eb8bd9c3f3d1a","repo":"iflytek/astron-agent","slug":"workflow-artifact-content-type-mismatch","errorCode":"WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH","errorMessage":"WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH","messagePattern":"WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH","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":190,"sourceCode":"            validateOoxmlContainer(file, OOXML_MAIN_CONTENT_TYPE_BY_EXTENSION.get(extension));\n        } else if (OLE_ROOT_ENTRIES_BY_EXTENSION.containsKey(extension)) {\n            validateOleContainer(file, OLE_ROOT_ENTRIES_BY_EXTENSION.get(extension));\n        }\n    }\n\n    private void validateOoxmlContainer(MultipartFile file, String expectedMainContentType) {\n        Path temporaryFile = null;\n        try {\n            temporaryFile = copyToTemporaryFile(file);\n            validateOoxmlResourceLimits(temporaryFile);\n            try (OPCPackage opcPackage =\n                    OPCPackage.open(temporaryFile.toFile(), PackageAccess.READ)) {\n                if (!hasExpectedMainPart(opcPackage, expectedMainContentType)) {\n                    throw new BusinessException(\n                            ResponseEnum.WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH);\n                }\n                if (containsActiveOoxmlContent(opcPackage)) {\n                    throw new BusinessException(\n                            ResponseEnum.WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH);\n                }\n            }\n        } catch (BusinessException exception) {\n            throw exception;\n        } catch (Exception exception) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH);\n        } finally {\n            if (temporaryFile != null) {\n                try {\n                    Files.deleteIfExists(temporaryFile);\n                } catch (IOException ignored) {\n                    // The temporary file contains untrusted data and must never be reused. The JVM\n                    // temp directory remains the final cleanup boundary if immediate deletion fails.\n                    temporaryFile.toFile().deleteOnExit();\n                }\n            }\n        }","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java#L172-L208","documentation":"Explicitly thrown at the hasExpectedMainPart check in validateOoxmlContainer: the OPC package opened successfully but lacks an internal main-document part of the expected content type reached via the core-document (or strict core-document) relationship. The container is ZIP/OOXML-like but is not a genuine Word/Excel/PowerPoint document of the claimed extension.","triggerScenarios":"A generic zip or an OOXML package of a different type renamed to .docx/.xlsx/.pptx; a package whose [Content_Types].xml or core-document relationship was stripped or corrupted so the main part's content type does not equal the expected constant.","commonSituations":"Renamed zip archives (e.g. EPUB, JAR, or custom OOXML-adjacent formats accepted by Tika as application/zip); template/partial Office files missing the main part; hand-crafted or tool-mangled packages.","solutions":["Verify the file is a real docx/xlsx/pptx by opening it in the corresponding Office application; re-export/re-save it if it fails.","Do not rename other zip-based files to an Office extension — upload .zip as zip instead.","If the file is a valid Office document, check that it was not truncated during upload (compare checksums with the source)."],"exampleFix":"// before\ncp archive.zip report.docx   // rejected\n// after\nupload archive.zip with .zip extension, or re-save the real document as .docx","handlingStrategy":"validation","validationCode":"try (ZipFile zip = new ZipFile(path)) {\n    boolean looksLikeOoxml = zip.getEntry(\"[Content_Types].xml\") != null;\n    // also verify the core-document part exists; otherwise fix extension or re-save\n}","typeGuard":null,"tryCatchPattern":"try { validator.validate(file); } catch (BusinessException e) { /* main-part missing: instruct user the file is not a genuine docx/xlsx/pptx of the claimed kind */ }","preventionTips":["Never rename arbitrary zip files to Office extensions; upload them as .zip.","Open the file in the matching Office app as a sanity check before upload.","Compare upload checksums with the source to rule out truncation."],"tags":["file-upload","ooxml","poi","office","validation"],"backgroundTag":"type-mismatch","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"}