{"record":{"id":"f203698404365d04","repo":"apache/seatunnel","slug":"table-schema-get-failed-f20369","errorCode":"TABLE_SCHEMA_GET_FAILED","errorMessage":"Get table schema from file [%s] failed","messagePattern":"Get table schema from file \\[(.+?)\\] failed","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/BaseFileSource.java","lineNumber":139,"sourceCode":"                default:\n                    // never got in there\n                    throw new FileConnectorException(\n                            CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT,\n                            \"SeaTunnel does not supported this file format\");\n            }\n        } else {\n            if (filePaths.isEmpty()) {\n                userDefinedCatalogTable = buildCatalogTableForEmptyPath(path, fileFormat);\n            } else {\n                try {\n                    SeaTunnelRowType rowType =\n                            readStrategy.getSeaTunnelRowTypeInfo(filePaths.get(0));\n                    userDefinedCatalogTable = CatalogTableUtil.getCatalogTable(\"default\", rowType);\n                } catch (FileConnectorException e) {\n                    String errorMsg =\n                            String.format(\n                                    \"Get table schema from file [%s] failed\", filePaths.get(0));\n                    throw new FileConnectorException(\n                            CommonErrorCodeDeprecated.TABLE_SCHEMA_GET_FAILED, errorMsg, e);\n                }\n            }\n        }\n        this.catalogTable =\n                documentRoutingEnabled\n                        ? MarkdownKnowledgeSyncMetadata.withMetadata(userDefinedCatalogTable)\n                        : userDefinedCatalogTable;\n    }\n\n    private CatalogTable buildCatalogTableForEmptyPath(String path, FileFormat fileFormat) {\n        if (fileFormat != FileFormat.BINARY\n                && fileFormat != FileFormat.MARKDOWN\n                && fileFormat != FileFormat.PDF) {\n            // Preserve the legacy simple-text fallback for formats that still infer schema from\n            // the first concrete file.\n            return CatalogTableUtil.buildSimpleTextTable();\n        }","sourceCodeStart":121,"sourceCodeEnd":157,"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/BaseFileSource.java#L121-L157","documentation":"When no user-defined schema is given, BaseFileSource infers the schema by calling readStrategy.getSeaTunnelRowTypeInfo on the first discovered file. If that read/parse fails with FileConnectorException, the error is rethrown as TABLE_SCHEMA_GET_FAILED with a message naming the file that failed (BaseFileSource.java:139).","triggerScenarios":"Automatic schema inference over the first file at filePaths.get(0) fails — e.g. corrupt or empty file, format mismatch (file is not actually the declared format), unreadable/permission-denied first file, or a parse error inside the format reader.","commonSituations":"First file in the directory is a partial write or wrong format; encoding issues in text/json files; parquet/ORC metadata corrupt; the first listed file was deleted between listing and read.","solutions":["Open and validate the named file: confirm it is readable and matches the declared file_format_type.","Replace or remove the corrupt/empty first file from the directory.","Add an explicit user-defined schema (for json/text/csv) to skip inference.","If the file is fine, check connector/format-specific errors in the wrapped cause for the real parse failure."],"exampleFix":"// before\nfile_format_type = json   # schema inferred from corrupt file\n// after\nfile_format_type = json\nschema = { fields { id bigint, name string } }","handlingStrategy":"try-catch","validationCode":"// Confirm the first file parses before submitting\nPath first = /* first file from listing */;\nFileStatus st = fs.getFileStatus(first);\nif (st.getLen() == 0) throw new IllegalStateException(\"First file is empty: \" + first);","typeGuard":null,"tryCatchPattern":"try {\n    // initialize source\n} catch (FileConnectorException e) {\n    if (CommonErrorCodeDeprecated.TABLE_SCHEMA_GET_FAILED.equals(e.getErrorCode())) {\n        // e.getCause() is the per-file FileConnectorException from getSeaTunnelRowTypeInfo\n        log.error(\"Fix or remove the named file, or provide an explicit schema\", e);\n    }\n    throw e;\n}","preventionTips":["Declare an explicit schema for json/text/csv to bypass inference.","Keep directories free of partial/temp files (e.g. _temporary, .crc, part-...tmp).","Verify first-file format matches file_format_type after uploads."],"tags":["schema","file","inference"],"backgroundTag":"file-read-failed","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"}