{"record":{"id":"fad062c3104ec1fa","repo":"apache/beam","slug":"unsupported-beam-to-json-type","errorCode":null,"errorMessage":"Unsupported Beam to JSON type: {}","messagePattern":"Unsupported Beam to JSON type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JsonUtils.java","lineNumber":191,"sourceCode":"      case STRING:\n        propertySchema = StringSchema.builder();\n        break;\n      case BOOLEAN:\n        propertySchema = BooleanSchema.builder();\n        break;\n      case ARRAY:\n      case ITERABLE:\n        Schema.FieldType fieldType = Optional.ofNullable(beamType.getCollectionElementType()).get();\n        propertySchema = ArraySchema.builder().allItemSchema(jsonPropertyFromBeamType(fieldType));\n        break;\n      case ROW:\n        Schema rowSchema = Optional.ofNullable(beamType.getRowSchema()).get();\n        propertySchema = jsonSchemaBuilderFromBeamSchema(rowSchema);\n        break;\n\n        // add more Beam to JSON types\n      default:\n        throw new IllegalArgumentException(\"Unsupported Beam to JSON type: \" + beamType);\n    }\n\n    if (beamType.getNullable()) {\n      propertySchema = propertySchema.nullable(true);\n    }\n\n    return propertySchema.build();\n  }\n\n  public static Schema beamSchemaFromJsonSchema(String jsonSchemaStr) {\n    org.everit.json.schema.ObjectSchema jsonSchema = jsonSchemaFromString(jsonSchemaStr);\n    return beamSchemaFromJsonSchema(jsonSchema);\n  }\n\n  private static Schema beamSchemaFromJsonSchema(org.everit.json.schema.ObjectSchema jsonSchema) {\n    Schema.Builder beamSchemaBuilder = Schema.builder();\n    Map<String, org.everit.json.schema.Schema> properties =\n        new HashMap<>(jsonSchema.getPropertySchemas());","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JsonUtils.java#L173-L209","documentation":"JsonUtils.jsonPropertyFromBeamType maps Beam Schema.FieldTypes to JSON-Schema property schemas. The switch only supports a fixed set of Beam types; any other FieldType (e.g. logical types or unmapped types) hits the default branch and throws this IllegalArgumentException. It indicates the Beam-to-JSON conversion does not cover the given type.","triggerScenarios":"Calling JsonUtils.toJsonObject/schema conversion APIs (e.g. JsonUtils.fromBeamSchema paths that build JSON Schema) with a Beam field whose FieldType is not one of the explicitly mapped types (BYTES, logical types, or other unsupported kinds).","commonSituations":"Adding a new field type (e.g. a custom logical type) to a Beam schema that is then exported to JSON Schema; schema evolution introducing a type the JSON converter predates.","solutions":["Change the Beam schema field to a supported type (string, integer, number, boolean, row, array, map as supported)","Add a mapping case in JsonUtils.jsonPropertyFromBeamType for the new Beam type (the comment explicitly says 'add more Beam to JSON types')","Pre-check field types before conversion and skip/translate unsupported ones","Wrap conversion in try-catch for IllegalArgumentException and surface a clearer per-field message"],"exampleFix":"// before\nSchema.FieldType t = Schema.FieldType.logicalType(new MyCustomType());\nJsonUtils.jsonPropertyFromBeamType(t); // throws\n// after\nSchema.FieldType t = Schema.FieldType.STRING; // or add a case for the logical type in JsonUtils","handlingStrategy":"validation","validationCode":"static boolean isJsonMappable(Schema.FieldType t) {\n  switch (t.getTypeName()) {\n    case STRING: case INT64: case INT32: case DOUBLE: case BOOLEAN:\n    case ROW: case ARRAY: case MAP: return true;\n    default: return false;\n  }\n}\n// reject fields up-front:\nschema.getFields().stream()\n  .filter(f -> !isJsonMappable(f.getType()))\n  .forEach(f -> { throw new IllegalArgumentException(\"Field \" + f.getName() + \" unsupported for JSON\"); });","typeGuard":"static boolean isPrimitiveOrStructured(Schema.FieldType t) {\n  return t.getTypeName().isPrimitiveType() || t.getTypeName() == Schema.TypeName.ROW;\n}","tryCatchPattern":"try {\n  JsonSchema js = jsonPropertyFromBeamType(beamType);\n} catch (IllegalArgumentException e) {\n  log.warn(\"Skipping unmappable Beam type: {}\", e.getMessage());\n}","preventionTips":["Restrict schemas exported to JSON to primitives, rows, arrays, and maps","Avoid custom logical types unless JsonUtils has a mapping for them","Check the Beam version's supported type list before schema evolution","Add per-field pre-validation before calling the converter"],"tags":["java","json-schema","schemas","type-conversion"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}