{"record":{"id":"8ef03927c61cf1df","repo":"apache/seatunnel","slug":"common-error-code-11","errorCode":"COMMON_ERROR_CODE-11","errorMessage":"User must defined schema for xml file type","messagePattern":"User must defined schema for xml file type","errorType":"exception","errorClass":"FileConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/XmlReadStrategy.java","lineNumber":221,"sourceCode":"            saxReader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);\n            saxReader.setFeature(DISALLOW_DOCTYPE_DECL, true);\n            saxReader.setFeature(EXTERNAL_GENERAL_ENTITIES, false);\n            saxReader.setFeature(EXTERNAL_PARAMETER_ENTITIES, false);\n            saxReader.setFeature(LOAD_EXTERNAL_DTD, false);\n            saxReader.setEntityResolver(\n                    (publicId, systemId) -> new InputSource(new StringReader(\"\")));\n        } catch (SAXException e) {\n            throw new FileConnectorException(\n                    FileConnectorErrorCode.FILE_READ_FAILED,\n                    \"Failed to initialize secure XML parser while reading file [\" + filePath + \"]\",\n                    e);\n        }\n        return saxReader;\n    }\n\n    @Override\n    public SeaTunnelRowType getSeaTunnelRowTypeInfo(String path) throws FileConnectorException {\n        throw new FileConnectorException(\n                CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION,\n                \"User must defined schema for xml file type\");\n    }\n\n    @Override\n    public void setCatalogTable(CatalogTable catalogTable) {\n        SeaTunnelRowType rowType = catalogTable.getSeaTunnelRowType();\n        if (ArrayUtils.isEmpty(rowType.getFieldNames())\n                || ArrayUtils.isEmpty(rowType.getFieldTypes())) {\n            throw new FileConnectorException(\n                    CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT,\n                    \"Schema information is undefined or misconfigured, please check your configuration file.\");\n        }\n\n        String partitionPath = getPathForPartitionInference(null);\n        if (readColumns.isEmpty()) {\n            this.seaTunnelRowType = rowType;\n            this.seaTunnelRowTypeWithPartition = mergePartitionTypes(partitionPath, rowType);","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/XmlReadStrategy.java#L203-L239","documentation":"XmlReadStrategy requires the user to declare the schema explicitly via a catalog table (schema in the config). getSeaTunnelRowTypeInfo is the path-inferred-schema hook, and XML inference is not implemented, so it unconditionally throws UNSUPPORTED_OPERATION.","triggerScenarios":"A SeaTunnel XML file source runs without a user-defined schema, so the framework calls getSeaTunnelRowTypeInfo(path) to auto-derive the row type from the file.","commonSituations":"Users coming from JSON/CSV sources assume schema auto-inference works for XML files too and omit the schema block in their source config.","solutions":["Define the schema explicitly in the source config (schema.fields with name/type) so setCatalogTable is used instead of inference.","Switch to a format that supports schema inference (e.g. JSON/CSV) if explicit schema is not desired.","Upgrade SeaTunnel if a newer version supports XML schema inference."],"exampleFix":"// before\nsource {\n  LocalFile {\n    file_format_type = \"xml\"\n  }\n}\n// after\nsource {\n  LocalFile {\n    file_format_type = \"xml\"\n    schema = {\n      fields {\n        id = int\n        name = string\n      }\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"if (config.getFileFormatType().equalsIgnoreCase(\"xml\") && (config.getSchema() == null || config.getSchema().isEmpty())) {\n    throw new IllegalArgumentException(\"XML file source requires an explicit schema block\");\n}","typeGuard":"boolean hasSchema(Config c) { return c.hasPath(\"schema.fields\") && !c.getConfig(\"schema.fields\").isEmpty(); }","tryCatchPattern":null,"preventionTips":["Always declare schema.fields for xml file_format_type.","Do not rely on schema inference for XML sources.","Pin connector docs/examples for XML before upgrading."],"tags":["file-connector","xml","schema","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}