iflytek/astron-agent · warning · BusinessException
WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH
WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH
Error message
WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH
What it means
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.
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).
Example fix
// before cp archive.zip report.docx // rejected // after upload archive.zip with .zip extension, or re-save the real document as .docx
Defensive patterns
Strategy: validation
Validate before calling
try (ZipFile zip = new ZipFile(path)) {
boolean looksLikeOoxml = zip.getEntry("[Content_Types].xml") != null;
// also verify the core-document part exists; otherwise fix extension or re-save
} Try / catch
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 */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/860eb8bd9c3f3d1a.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java:190
validateOoxmlContainer(file, OOXML_MAIN_CONTENT_TYPE_BY_EXTENSION.get(extension));
} else if (OLE_ROOT_ENTRIES_BY_EXTENSION.containsKey(extension)) {
validateOleContainer(file, OLE_ROOT_ENTRIES_BY_EXTENSION.get(extension));
}
}
private void validateOoxmlContainer(MultipartFile file, String expectedMainContentType) {
Path temporaryFile = null;
try {
temporaryFile = copyToTemporaryFile(file);
validateOoxmlResourceLimits(temporaryFile);
try (OPCPackage opcPackage =
OPCPackage.open(temporaryFile.toFile(), PackageAccess.READ)) {
if (!hasExpectedMainPart(opcPackage, expectedMainContentType)) {
throw new BusinessException(
ResponseEnum.WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH);
}
if (containsActiveOoxmlContent(opcPackage)) {
throw new BusinessException(
ResponseEnum.WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH);
}
}
} catch (BusinessException exception) {
throw exception;
} catch (Exception exception) {
throw new BusinessException(ResponseEnum.WORKFLOW_ARTIFACT_CONTENT_TYPE_MISMATCH);
} finally {
if (temporaryFile != null) {
try {
Files.deleteIfExists(temporaryFile);
} catch (IOException ignored) {
// The temporary file contains untrusted data and must never be reused. The JVM
// temp directory remains the final cleanup boundary if immediate deletion fails.
temporaryFile.toFile().deleteOnExit();
}
}
}View on GitHub (pinned to 5e758547a8)