{"record":{"id":"3bf3184399ff9ed1","repo":"apache/seatunnel","slug":"fileconnectorerrorcode-file-type-invalid","errorCode":"FileConnectorErrorCode.FILE_TYPE_INVALID","errorMessage":"This file [%s] is not a orc file, please check the format of this file","messagePattern":"This file \\[(.+?)\\] is not a orc file, please check the format of this file","errorType":"error_code","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/OrcReadStrategy.java","lineNumber":92,"sourceCode":"import java.util.List;\nimport java.util.Map;\n\nimport static org.apache.seatunnel.api.table.type.TypeUtil.canConvert;\nimport static org.apache.seatunnel.connectors.seatunnel.file.sink.writer.OrcWriteStrategy.buildFieldWithRowType;\n\n@Slf4j\npublic class OrcReadStrategy extends AbstractReadStrategy {\n    private static final long MIN_SIZE = 16 * 1024;\n\n    @Override\n    public void read(String path, String tableId, Collector<SeaTunnelRow> output)\n            throws FileConnectorException, IOException {\n        if (Boolean.FALSE.equals(checkFileType(path))) {\n            String errorMsg =\n                    String.format(\n                            \"This file [%s] is not a orc file, please check the format of this file\",\n                            path);\n            throw new FileConnectorException(FileConnectorErrorCode.FILE_TYPE_INVALID, errorMsg);\n        }\n\n        Charset charset = StandardCharsets.UTF_8;\n        if (pluginConfig != null) {\n            charset =\n                    ReadonlyConfig.fromConfig(pluginConfig)\n                            .getOptional(FileBaseSourceOptions.ENCODING)\n                            .map(Charset::forName)\n                            .orElse(StandardCharsets.UTF_8);\n        }\n\n        Map<String, String> partitionsMap = parsePartitionsByPath(path);\n        try (Reader reader =\n                hadoopFileSystemProxy.doWithHadoopAuth(\n                        (configuration, userGroupInformation) -> {\n                            OrcFile.ReaderOptions readerOptions =\n                                    OrcFile.readerOptions(configuration);\n                            return OrcFile.createReader(new Path(path), readerOptions);","sourceCodeStart":74,"sourceCodeEnd":110,"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/OrcReadStrategy.java#L74-L110","documentation":"OrcReadStrategy.read() verifies the file actually has the ORC magic header before opening it. When checkFileType returns false, the file is not a valid ORC file and reading is aborted with FILE_TYPE_INVALID. This guards against feeding mislabeled or corrupt files to the ORC reader.","triggerScenarios":"Calling OrcReadStrategy.read(path) on a file whose first bytes are not 'ORC' (plain text/JSON/CSV renamed to .orc, empty file, or truncated download).","commonSituations":"Directory mixes formats but file_type=orc is configured; an upstream job wrote text files into the ORC directory; partial upload left a non-ORC zero-byte file; using FileFormatOption ORC with a path of mixed extensions.","solutions":["Check the file's header bytes (should start with 'ORC') to confirm its real format.","Correct the file_type in the source config to match the actual file format (e.g. text/parquet).","Remove or regenerate the corrupt/mislabeled file.","Re-run the upstream writer if the file was truncated mid-write."],"exampleFix":"// before\nfile_format_type = orc   # file is actually parquet\n// after\nfile_format_type = parquet","handlingStrategy":"validation","validationCode":"// check ORC magic before configuring source\nhead -c 3 file.orc  # must print 'ORC'","typeGuard":"function looksLikeOrc(bytes) { return bytes.length >= 3 && bytes[0]===0x4F && bytes[1]===0x52 && bytes[2]===0x43; }","tryCatchPattern":"try { strategy.read(path); } catch (FileConnectorException e) { if (e.getErrorCode() == FileConnectorErrorCode.FILE_TYPE_INVALID) { log.error(\"{} is not ORC; detect actual format\", path); } throw e; }","preventionTips":["Match file_type in config to the actual on-disk format","Keep different formats in separate directories","Verify uploads completed before ingesting files","Sample file headers when onboarding new data sources"],"tags":["orc","file-format","file-source","validation"],"backgroundTag":"incompatible-source-type","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"}