{"record":{"id":"c498124f95a48184","repo":"apache/beam","slug":"unsupported-field-type-fieldtype-mongodbutils","errorCode":null,"errorMessage":"Unsupported field type: \" + fieldType","messagePattern":"Unsupported field type: \" \\+ fieldType","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbUtils.java","lineNumber":202,"sourceCode":"          rowMap.put(\n              String.valueOf(entry.getKey()), convertFromBsonValue(entry.getValue(), valueType));\n        }\n        return rowMap;\n      case ROW:\n        Schema rowSchema = fieldType.getRowSchema();\n        if (rowSchema == null) {\n          throw new IllegalArgumentException(\"Row schema cannot be null for type: \" + fieldType);\n        }\n        if (value instanceof Map) {\n          return toRow((Map<?, ?>) value, rowSchema);\n        } else {\n          throw new IllegalArgumentException(\n              \"Cannot convert value of type \"\n                  + (value != null ? value.getClass().getName() : \"null\")\n                  + \" to Row\");\n        }\n      default:\n        throw new IllegalArgumentException(\"Unsupported field type: \" + fieldType);\n    }\n  }\n}\n","sourceCodeStart":184,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbUtils.java#L184-L206","documentation":"convertFromBsonValue's switch over FieldType TypeName has no case for the given field type (e.g. LOGICAL_TYPE, DATETIME, BYTES variants not handled by this helper), so it falls into default and throws. It means the MongoDbIO schema converter does not support converting that FieldType from a BSON value.","triggerScenarios":"A schema field uses a FieldType whose TypeName is not among the handled primitives/collection/MAP/ROW cases — e.g. custom logical types, portable bytes, or unsupported logical types like instant/decimal depending on version — while reading documents via toRow.","commonSituations":"Custom logical types added by user code; schema inferred from Java types that map to unhandled Beam logical types; Beam version differences where new FieldTypes (e.g. new logical types) postdate the connector's converter.","solutions":["Change the field to a supported primitive type (STRING, INT64, DOUBLE, BOOLEAN, BYTES as handled) and convert in user code.","Wrap values as STRING (e.g. timestamps as ISO strings) if the connector's converter lacks a case for the logical type.","Upgrade Apache Beam — newer versions may have added support for the FieldType in MongoDbUtils.","Implement a custom schema mapping (DoFn) instead of relying on the connector's automatic conversion."],"exampleFix":"// before\nField.of(\"createdAt\", FieldType.logicalType(new MyInstantLogicalType()))\n// after: store as string, parse later\nField.of(\"createdAt\", FieldType.STRING)","handlingStrategy":"validation","validationCode":"Set<TypeName> supported = Set.of(TypeName.STRING, TypeName.INT64, TypeName.INT32, TypeName.DOUBLE, TypeName.FLOAT, TypeName.BOOLEAN, TypeName.BYTES, TypeName.ARRAY, TypeName.ITERABLE, TypeName.MAP, TypeName.ROW);\nschema.getFields().forEach(f -> {\n  if (!supported.contains(f.getType().getTypeName())) {\n    throw new IllegalStateException(\"Unsupported field type in MongoDbIO schema: \" + f.getType());\n  }\n});","typeGuard":null,"tryCatchPattern":"try {\n  Row row = toRow(doc, schema);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unsupported field type\")) {\n    throw new SchemaConfigurationException(\"Use only types supported by MongoDbUtils: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Restrict schemas to primitive types plus ARRAY/MAP/ROW for MongoDB sources.","Convert logical types (timestamps, decimals) to STRING/INT64 before ingestion.","Check the connector's supported types for your Beam version before designing the schema."],"tags":["mongodb","apache-beam","schema","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}