{"record":{"id":"fc8d78b338e39cfc","repo":"apache/seatunnel","slug":"field-is-null","errorCode":"FIELD_IS_NULL","errorMessage":"FIELD_IS_NULL","messagePattern":"FIELD_IS_NULL","errorType":"error_code","errorClass":"MilvusConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-milvus/src/main/java/org/apache/seatunnel/connectors/seatunnel/milvus/utils/sink/MilvusSinkConverter.java","lineNumber":333,"sourceCode":"        String partitionKeyField = getPartitionKeyField(catalogTable, config);\n\n        JsonObject data = new JsonObject();\n        Gson gson = new Gson();\n        for (int i = 0; i < seaTunnelRowType.getFieldNames().length; i++) {\n            String fieldName = seaTunnelRowType.getFieldNames()[i];\n            Boolean isJson = jsonFields.contains(fieldName);\n            if (autoId && isPrimaryKeyField(primaryKey, fieldName)) {\n                continue; // if create table open AutoId, then don't need insert data with\n                // primaryKey field.\n            }\n\n            SeaTunnelDataType<?> fieldType = seaTunnelRowType.getFieldType(i);\n            Object value = element.getField(i);\n            if (value == null) {\n                Column column = catalogTable.getTableSchema().getColumn(fieldName);\n                if (!allowNullableField(\n                        column, primaryKey, partitionKeyField, enableNullableField)) {\n                    throw new MilvusConnectorException(\n                            MilvusConnectionErrorCode.FIELD_IS_NULL, fieldName);\n                }\n                if (dynamicField != null\n                        && dynamicField.equals(fieldName)\n                        && config.get(ENABLE_DYNAMIC_FIELD)) {\n                    continue;\n                }\n                data.add(fieldName, JsonNull.INSTANCE);\n                continue;\n            }\n            // if the field is dynamic field, then parse the dynamic field\n            if (dynamicField != null\n                    && dynamicField.equals(fieldName)\n                    && config.get(ENABLE_DYNAMIC_FIELD)) {\n                JsonObject dynamicData = gson.fromJson(value.toString(), JsonObject.class);\n                dynamicData\n                        .entrySet()\n                        .forEach(","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-milvus/src/main/java/org/apache/seatunnel/connectors/seatunnel/milvus/utils/sink/MilvusSinkConverter.java#L315-L351","documentation":"MilvusSinkConverter.buildMilvusData throws FIELD_IS_NULL when a SeaTunnelRow field is null and the corresponding column does not permit null values. Milvus requires the primary key and partition key to be non-null; other fields are only nullable if declared nullable in the catalog schema or if the 'enable.nullable-field' option is turned on. The error message carries the offending field name.","triggerScenarios":"Writing a row whose field value is null for a column that is not nullable, is the primary key, or is the partition key, while allowNullableField(column, primaryKey, partitionKeyField, enableNullableField) returns false in buildMilvusData.","commonSituations":"Upstream source produces nulls (e.g. missing JSON keys, LEFT JOIN misses) that are passed straight into the Milvus sink; writing to a Milvus collection whose primary/partition key column receives null; user forgot to enable the nullable-field option even though the collection schema allows nulls.","solutions":["Filter out or default null values upstream before writing to the Milvus sink (e.g. a SQL transform with COALESCE/NVL).","Set the sink option 'enable.nullable-field' = true if the target Milvus collection truly allows null for this field.","Verify the catalog table schema marks the column nullable so allowNullableField passes.","Ensure the primary key and partition key columns are never null in your data."],"exampleFix":"// before (row with null field)\nrow.setField(2, null); // field 'embedding_desc' is not nullable\n// after\nrow.setField(2, defaultValueIfNull(actualValue)); // or set enable.nullable-field=true","handlingStrategy":"validation","validationCode":"// before writing to Milvus sink\nfor (int i = 0; i < rowType.getFieldNames().length; i++) {\n    if (element.getField(i) == null && !nullableFields.contains(rowType.getFieldNames()[i])) {\n        throw new IllegalArgumentException(\"Field \" + rowType.getFieldNames()[i] + \" must not be null\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try { sinkWriter.write(row); } catch (MilvusConnectorException e) { if (MilvusConnectionErrorCode.FIELD_IS_NULL.equals(e.getErrorCode())) { log.warn(\"Null non-nullable field: {}\", e.getMessage()); } else { throw e; } }","preventionTips":["Coalesce nulls to defaults in a SQL transform before the Milvus sink","Enable enable.nullable-field only when the Milvus collection schema actually permits nulls","Never allow null primary/partition key columns from upstream sources"],"tags":["milvus","null-value","sink","data-validation"],"backgroundTag":"empty-required-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}