{"record":{"id":"d11ab7054a4c87b6","repo":"apache/seatunnel","slug":"rowtype-cannot-be-null","errorCode":null,"errorMessage":"RowType cannot be null","messagePattern":"RowType cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java","lineNumber":128,"sourceCode":"\n        try {\n            return DriverManager.getConnection(url, properties);\n        } catch (SQLException e) {\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.CONNECT_FAILED,\n                    \"Failed to create connection to Databend: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    /** Convert a ResultSet row to SeaTunnelRow */\n    public static SeaTunnelRow convertToSeaTunnelRow(ResultSet resultSet, SeaTunnelRowType rowType)\n            throws SQLException {\n        if (resultSet == null) {\n            throw new IllegalArgumentException(\"ResultSet cannot be null\");\n        }\n        if (rowType == null) {\n            throw new IllegalArgumentException(\"RowType cannot be null\");\n        }\n\n        int arity = rowType.getFieldNames().length;\n        Object[] fields = new Object[arity];\n        log.info(\"Converting ResultSet to SeaTunnelRow with {} fields\", arity);\n\n        try {\n            for (int i = 0; i < arity; i++) {\n                int columnIndex = i + 1;\n                String fieldName = rowType.getFieldName(i);\n                SeaTunnelDataType<?> fieldType = rowType.getFieldType(i);\n\n                try {\n                    Object value = getFieldValue(resultSet, columnIndex, fieldType);\n                    fields[i] = value;\n\n                    if (value == null) {\n                        log.info(\"Field {} ({}) [{}]: null\", i, fieldName, fieldType.getSqlType());","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java#L110-L146","documentation":"DatabendUtil.convertToSeaTunnelRow also requires a non-null SeaTunnelRowType; a null rowType triggers IllegalArgumentException('RowType cannot be null'). The row type supplies the field names/arity used to size and populate the SeaTunnelRow, so conversion is impossible without it.","triggerScenarios":"Passing null as the SeaTunnelRowType argument - typically because the reader's catalog/type info was not initialized, getProducedType() returned null, or a variable holding the row type was never assigned before conversion.","commonSituations":"Custom readers built on the util before catalog initialization completed; config parsing that failed to derive the schema (e.g. missing schema option) silently yielding a null type; unit tests passing null.","solutions":["Initialize the SeaTunnelRowType from the catalog table schema before any row conversion occurs","If the type is derived from config (e.g. schema option), verify that configuration produced a valid row type","Guard the call: check rowType != null and fail fast with a clear message if the schema was never built"],"exampleFix":"// before\nSeaTunnelRow row = DatabendUtil.convertToSeaTunnelRow(resultSet, rowType);\n// after\nObjects.requireNonNull(rowType, \"rowType must be initialized from catalog schema before conversion\");\nSeaTunnelRow row = DatabendUtil.convertToSeaTunnelRow(resultSet, rowType);","handlingStrategy":"type-guard","validationCode":"if (rowType == null) { throw new IllegalStateException(\"SeaTunnelRowType not initialized; ensure catalog schema was loaded\"); }","typeGuard":"if (rowType == null || rowType.getFieldNames().length == 0) { return; }","tryCatchPattern":"try { row = DatabendUtil.convertToSeaTunnelRow(rs, rowType); } catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"RowType cannot be null\")) { log.error(\"Schema/rowType was never initialized\"); }\n    throw e;\n}","preventionTips":["Build SeaTunnelRowType in the reader's initialization phase before any poll/read path runs","Fail fast at job startup if schema-derived options (e.g. schema) are absent so rowType is never null later","Unit-test catalog initialization to guarantee getProducedType() returns a populated type"],"tags":["databend","null-check","schema","argument-validation"],"backgroundTag":"null-argument","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"}