{"record":{"id":"33ece89c78c52100","repo":"apache/beam","slug":"converting-yaml-type-s-to-s-is-not-supported","errorCode":null,"errorMessage":"Converting YAML type '%s' to '%s' is not supported","messagePattern":"Converting YAML type '(.+?)' to '(.+?)' is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/YamlUtils.java","lineNumber":148,"sourceCode":"                          toBeamValue(field.withType(innerType), v, convertNamesToCamelCase)))\n              .collect(Collectors.toList());\n    }\n\n    if (yamlValue instanceof Map) {\n      if (fieldType.getTypeName() == Schema.TypeName.ROW) {\n        Schema nestedSchema =\n            Preconditions.checkNotNull(\n                fieldType.getRowSchema(),\n                \"Received a YAML '%s' type, but output schema field '%s' does not define a Row Schema\",\n                yamlValue.getClass(),\n                fieldType);\n        return toBeamRow((Map<String, Object>) yamlValue, nestedSchema, convertNamesToCamelCase);\n      } else if (fieldType.getTypeName() == Schema.TypeName.MAP) {\n        return yamlValue;\n      }\n    }\n\n    throw new UnsupportedOperationException(\n        String.format(\n            \"Converting YAML type '%s' to '%s' is not supported\", yamlValue.getClass(), fieldType));\n  }\n\n  @SuppressWarnings(\"nullness\")\n  public static Row toBeamRow(\n      @Nullable Map<String, Object> map, Schema rowSchema, boolean toCamelCase) {\n    if (map == null || map.isEmpty()) {\n      List<Field> requiredFields =\n          rowSchema.getFields().stream()\n              .filter(field -> !field.getType().getNullable())\n              .collect(Collectors.toList());\n      if (requiredFields.isEmpty()) {\n        return Row.nullRow(rowSchema);\n      } else {\n        throw new IllegalArgumentException(\n            String.format(\n                \"Received an empty Map, but output schema contains required fields: %s\",","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/YamlUtils.java#L130-L166","documentation":"toBeamValue only knows how to convert a limited set of YAML value types (scalars, lists, maps-to-row) to schema field types; anything else, or a type/field-type pairing with no conversion path, hits the final UnsupportedOperationException with the Java value class and target FieldType in the message.","triggerScenarios":"A YAML value's Java runtime type has no conversion for the target FieldType — e.g. a MAP field returns the raw yamlValue unchecked but scalar-to-LOGICAL/BYTES/DATETIME combinations, or a List where the field is not an array/iterable, reach the fall-through throw after the instanceof checks.","commonSituations":"YAML documents with dates/timestamps parsed into Date objects for DATETIME fields in older versions, binary data for BYTES fields, or mismatched schema (field declared INTEGER but YAML has a nested mapping).","solutions":["Align the YAML value type with the schema field type (e.g. provide a mapping where the schema expects a row).","Change the schema field type to match what the YAML actually contains.","Pre-convert unsupported YAML types (e.g. timestamps to strings, binary to base64 strings) before calling toBeamRow.","Upgrade Beam — YamlUtils gains more conversions over time.","Do a manual pre-pass: parse with SnakeYAML yourself and construct the Row field-by-field for exotic types."],"exampleFix":"// before (YAML)\ncreated: 2023-01-01T00:00:00Z // parsed as Date, unsupported target\n// after\ncreated: \"2023-01-01T00:00:00Z\" // string, or declare field as DATETIME supported in newer Beam","handlingStrategy":"type-guard","validationCode":"Object v = yamlMap.get(fieldName);\nSchema.TypeName t = schema.getField(fieldName).getType().getTypeName();\nif (v instanceof String && !(t == Schema.TypeName.STRING || t.isNumericType()))\n  throw new IllegalArgumentException(\"Unsupported YAML scalar for \" + t);\nif (v instanceof Map && !(t == Schema.TypeName.ROW || t == Schema.TypeName.MAP))\n  throw new IllegalArgumentException(\"Mapping not allowed for \" + t);\nif (v instanceof List && !(t == Schema.TypeName.ARRAY || t == Schema.TypeName.ITERABLE))\n  throw new IllegalArgumentException(\"Sequence not allowed for \" + t);","typeGuard":"boolean yamlValueMatches(Object v, Schema.FieldType t) {\n  if (v == null) return t.getNullable();\n  switch (t.getTypeName()) {\n    case STRING: return v instanceof String || v instanceof Number || v instanceof Boolean;\n    case ROW: case MAP: return v instanceof Map;\n    case ARRAY: case ITERABLE: return v instanceof List;\n    default: return v instanceof String || v instanceof Number || v instanceof Boolean;\n  }\n}","tryCatchPattern":"try {\n  return YamlUtils.toBeamRow(yamlString, schema);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Converting YAML type\")) {\n    logger.warning(\"Unsupported YAML conversion: \" + e.getMessage());\n    return null; // or dead-letter the record\n  }\n  throw e;\n}","preventionTips":["Quote timestamps/dates as strings in YAML","Keep YAML scalars plain (strings/numbers/booleans)","Match schema field types to actual YAML shapes before conversion","Test conversion on representative documents in CI"],"tags":["java","yaml","schema","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}