{"record":{"id":"f615049e2cfe6620","repo":"apache/beam","slug":"value-value-of-class-valueclass-is-not-a-supported-type-for","errorCode":null,"errorMessage":"Value ${value} of class ${valueClass} is not a supported type for logical type ${logicalTypeName} (${logicalType}). Underlying avro built-in raw type should be instance of ${desiredRawType}. However it is instance of ${rawTypeClass} and has value ${rawValue} .Generic data has conversion ${conversion}, convertedType ${convertedType}","messagePattern":"Value (.+?) of class (.+?) is not a supported type for logical type (.+?) \\((.+?)\\)\\. Underlying avro built-in raw type should be instance of (.+?)\\. However it is instance of (.+?) and has value (.+?) \\.Generic data has conversion (.+?), convertedType (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java","lineNumber":1807,"sourceCode":"      Conversion<?> conversion,\n      Class<?> convertedType) {\n    String msg =\n        String.format(\n            \"Value %s of class %s is not a supported type for logical type %s (%s). \"\n                + \"Underlying avro built-in raw type should be instance of %s. \"\n                + \"However it is instance of %s and has value %s .\"\n                + \"Generic data has conversion %s, convertedType %s\",\n            value,\n            value.getClass(),\n            logicalType.getName(),\n            logicalType,\n            desiredRawType,\n            rawType.getClass(),\n            rawType,\n            conversion,\n            convertedType);\n    if (!desiredRawType.isInstance(rawType)) {\n      throw new IllegalArgumentException(msg);\n    }\n    return (T) rawType;\n  }\n}\n","sourceCodeStart":1789,"sourceCodeEnd":1812,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java#L1789-L1812","documentation":"checkRawType validates, during Avro logical-type value conversion, that the raw (underlying built-in Avro type) value actually is an instance of the class the logical type expects (e.g., a decimal logical type expects a ByteBuffer/Long raw value). If not — usually because a Conversion is missing, wrong, or the value bypassed normal Avro conversion — a detailed IllegalArgumentException is thrown describing the value, its class, the logical type, the expected raw type, and the registered conversion.","triggerScenarios":"Calling convertAvroFieldStrict on a field whose Avro schema carries a logicalType where the value stored in the GenericRecord is the raw built-in type but not of the expected class — e.g., a 'decimal' logical type whose value is a String/Integer instead of ByteBuffer or CharSequence, or a logical type with no Conversion registered in the GenericData so the raw value reaches checkRawType unconverted.","commonSituations":"Reading Avro data written by another tool that stored logical-type fields with a different underlying raw type; forgetting to register a Conversion for a custom logical type (GenericData.get().addLogicalTypeConversion(...)); Avro version differences that changed the raw representation of a logical type (e.g., timestamp-millis); decimal values deserialized as GenericFixed instead of BigDecimal.","solutions":["Register the proper Conversion for the logical type on the GenericData used (e.g., Conversions.DecimalConversion via genericData.addLogicalTypeConversion).","Verify the writer schema: confirm the underlying Avro raw type matches the logical type spec (decimal -> bytes/fixed, timestamp-millis -> long, etc.) and fix the data or schema if it doesn't.","Pre-convert the value yourself (MapElements) to the expected raw type before strict conversion.","If reading files, ensure reader and writer schemas agree via Avro schema resolution instead of forcing strict conversion."],"exampleFix":"// before\nGenericData genericData = new GenericData();\nObject v = AvroUtils.convertAvroFieldStrict(raw, schema, fieldType); // decimal stored as raw, no conversion\n\n// after\nGenericData genericData = new GenericData();\ngenericData.addLogicalTypeConversion(new Conversions.DecimalConversion());","handlingStrategy":"validation","validationCode":"Schema.Type raw = schema.getType();\nLogicalType lt = schema.getLogicalType();\nif (lt != null) {\n  boolean ok =\n    (lt instanceof Conversions.DecimalConversion && (raw == Schema.Type.BYTES || raw == Schema.Type.FIXED))\n    || (lt instanceof TimeConversions.TimestampMillisConversion && raw == Schema.Type.LONG);\n  if (!ok) throw new IllegalStateException(\"unexpected raw type \" + raw + \" for logical type \" + lt);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return AvroUtils.convertAvroFieldStrict(value, schema, fieldType);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"is not a supported type for logical type\")) {\n    // register missing Conversion or repair the writer schema\n  } else { throw e; }\n}","preventionTips":["Always register logical-type Conversions (decimal, timestamp, etc.) on the GenericData used for conversion.","Validate writer schemas in CI against the logical-type spec.","Log the raw value class when logical-type conversions fail to spot writer/reader mismatches early."],"tags":["avro","beam","logical-type","type-mismatch","conversion"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}