{"record":{"id":"e718c8e939579820","repo":"apache/seatunnel","slug":"commonerrorcodedeprecated-unsupported-operation-e718c8","errorCode":"CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION","errorMessage":"User must defined schema for json file type","messagePattern":"User must defined schema for json file type","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/JsonReadStrategy.java","lineNumber":152,"sourceCode":"                                    seaTunnelRow.setTableId(split.getTableId());\n                                    output.collect(seaTunnelRow);\n                                } catch (IOException e) {\n                                    String errorMsg =\n                                            String.format(\n                                                    \"Deserialize this jsonFile data [%s] failed, please check the origin data\",\n                                                    line);\n                                    throw new FileConnectorException(\n                                            FileConnectorErrorCode.DATA_DESERIALIZE_FAILED,\n                                            errorMsg,\n                                            e);\n                                }\n                            });\n        }\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 json file type\");\n    }\n}\n","sourceCodeStart":134,"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/reader/JsonReadStrategy.java#L134-L157","documentation":"JsonReadStrategy cannot infer a schema from JSON files (unlike ORC/Parquet), so getSeaTunnelRowTypeInfo always throws UNSUPPORTED_OPERATION. The library requires the user to explicitly define the schema for JSON file sources. Calling the schema-inference path without a configured schema fails immediately.","triggerScenarios":"Calling JsonReadStrategy.getSeaTunnelRowTypeInfo(path); using a JSON file source without setting schema { fields { ... } } so the connector falls back to schema inference from the file.","commonSituations":"Copy-pasting an ORC/Parquet file source config (which support auto schema) and switching file_type to json; creating a source programmatically without setting the row type; older configs missing the schema block.","solutions":["Add a schema block with fields to the JSON file source config.","If using ReadStrategy API directly, call setSeaTunnelRowTypeInfo(userDefinedRowType) before reading instead of relying on inference.","Switch to a self-describing format (ORC/Parquet) if you need automatic schema inference."],"exampleFix":"// before\nJson {\n  path = \"/data/logs.json\"\n  file_format_type = json\n}\n// after\nJson {\n  path = \"/data/logs.json\"\n  file_format_type = json\n  schema = {\n    fields {\n      id = int\n      name = string\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"// fail fast if schema is absent for json file source\nif (fileFormatType == \"json\" && (schema == null || schema.fields == null)) {\n  throw new IllegalArgumentException(\"schema.fields is required for json file sources\");\n}","typeGuard":"function hasSchema(config) { return config.schema != null && config.schema.fields != null && Object.keys(config.schema.fields).length > 0; }","tryCatchPattern":"try { rowType = strategy.getSeaTunnelRowTypeInfo(path); } catch (FileConnectorException e) { if (e.getCode() == CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION) { throw new IllegalStateException(\"Define schema in source config for json files\"); } throw e; }","preventionTips":["Always declare schema { fields { ... } } for json file sources","Do not reuse ORC/Parquet source templates for json without adding a schema","Prefer self-describing formats when schema inference is desired"],"tags":["json","file-source","schema","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}