{"record":{"id":"4bc9816fa96fb637","repo":"apache/beam","slug":"unsupported-underlying-type-for-parsing-logical-type-via","errorCode":null,"errorMessage":"Unsupported underlying type for parsing logical type via coder.","messagePattern":"Unsupported underlying type for parsing logical type via coder\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java","lineNumber":738,"sourceCode":"                entry -> fieldValueFromProto(mapKeyType, entry.getKey()),\n                entry -> fieldValueFromProto(mapValueType, entry.getValue())));\n  }\n\n  /** Converts logical type value from proto using a default type coder. */\n  private static Object logicalTypeFromProto(\n      FieldType baseType, FieldType inputType, LogicalTypeValue value) {\n    try {\n      PipedInputStream in = new PipedInputStream();\n      DataOutputStream stream = new DataOutputStream(new PipedOutputStream(in));\n      switch (baseType.getTypeName()) {\n        case INT64:\n          stream.writeLong(value.getValue().getAtomicValue().getInt64());\n          break;\n        case BYTES:\n          stream.write(value.getValue().getAtomicValue().getBytes().toByteArray());\n          break;\n        default:\n          throw new UnsupportedOperationException(\n              \"Unsupported underlying type for parsing logical type via coder.\");\n      }\n      stream.close();\n      return SchemaCoderHelpers.coderForFieldType(inputType).decode(in);\n    } catch (IOException e) {\n      throw new RuntimeException(e);\n    }\n  }\n\n  /** Converts logical type value to a proto using a default type coder. */\n  private static LogicalTypeValue logicalTypeToProto(\n      FieldType baseType, FieldType inputType, Object value) {\n    try {\n      PipedInputStream in = new PipedInputStream();\n      PipedOutputStream out = new PipedOutputStream(in);\n      SchemaCoderHelpers.coderForFieldType(inputType).encode(value, out);\n      out.close(); // Close required for toByteArray.\n      Object baseObject;","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java#L720-L756","documentation":"When a logical type value must be decoded via its representation coder, logicalTypeFromProto first reads the raw atomic representation from the proto (INT64, BYTES, etc.). If the stored atomic value's type is none of the supported cases, this UnsupportedOperationException is thrown because Beam cannot feed that representation into the coder's input stream.","triggerScenarios":"fieldValueFromProto → logicalTypeFromProto encounters a LogicalTypeValue whose value's AtomicTypeValue case is not INT64, DOUBLE, STRING, or BYTES while decoding through the coder-based path.","commonSituations":"Logical type representation changed between writer and reader versions (representation type mismatch); proto built by another language/SDK writing a different atomic case; hand-crafted protos in tests.","solutions":["Ensure the logical type's representation type is identical on write and read sides (same Beam version / same representation).","Inspect the stored AtomicTypeValue case and add/upgrade support in your Beam version.","If you control the logical type, change its representation to INT64, DOUBLE, STRING, or BYTES.","Avoid the coder path by registering an explicit LogicalType with proper getArgumentType/getBaseType so the non-coder path is used."],"exampleFix":"// before\n@Override\npublic FieldType getRepresentation() { return FieldType.iterable(FieldType.INT32); } // unsupported via coder path\n// after\n@Override\npublic FieldType getRepresentation() { return FieldType.BYTES; }","handlingStrategy":"type-guard","validationCode":"FieldType rep = logicalType.getRepresentation(); if (!(rep.getTypeName().isPrimitiveType())) throw new IllegalArgumentException(\"logical type representation must be a primitive for coder path\");","typeGuard":"boolean coderSafeRepresentation(FieldType rep) { switch (rep.getTypeName()) { case INT64: case DOUBLE: case STRING: case BYTES: return true; default: return false; } }","tryCatchPattern":"try { decodeValue(...); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"Unsupported underlying type for parsing logical type\")) { /* fix representation type */ } else { throw e; } }","preventionTips":["Use BYTES or another primitive as the logical type representation","Keep representation types stable across Beam versions","Register logical types by URN so the non-coder path is used","Test round-trip serialization of custom logical types"],"tags":["java","logical-type","unsupported-type","deserialization"],"backgroundTag":"unsupported-operation","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"}