{"record":{"id":"3c3105c8830a89a5","repo":"apache/beam","slug":"fieldtype-unexpected-fieldtype-gettypename","errorCode":null,"errorMessage":"FieldType unexpected +fieldType.getTypeName()","messagePattern":"FieldType unexpected \\+fieldType\\.getTypeName\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java","lineNumber":813,"sourceCode":"        return AtomicTypeValue.newBuilder().setByte((byte) value).build();\n      case INT16:\n        return AtomicTypeValue.newBuilder().setInt16((short) value).build();\n      case INT32:\n        return AtomicTypeValue.newBuilder().setInt32((int) value).build();\n      case INT64:\n        return AtomicTypeValue.newBuilder().setInt64((long) value).build();\n      case FLOAT:\n        return AtomicTypeValue.newBuilder().setFloat((float) value).build();\n      case DOUBLE:\n        return AtomicTypeValue.newBuilder().setDouble((double) value).build();\n      case STRING:\n        return AtomicTypeValue.newBuilder().setString((String) value).build();\n      case BOOLEAN:\n        return AtomicTypeValue.newBuilder().setBoolean((boolean) value).build();\n      case BYTES:\n        return AtomicTypeValue.newBuilder().setBytes(ByteString.copyFrom((byte[]) value)).build();\n      default:\n        throw new RuntimeException(\"FieldType unexpected \" + fieldType.getTypeName());\n    }\n  }\n\n  private static Object primitiveFromProto(FieldType fieldType, AtomicTypeValue value) {\n    switch (fieldType.getTypeName()) {\n      case BYTE:\n        return (byte) value.getByte();\n      case INT16:\n        return (short) value.getInt16();\n      case INT32:\n        return value.getInt32();\n      case INT64:\n        return value.getInt64();\n      case FLOAT:\n        return value.getFloat();\n      case DOUBLE:\n        return value.getDouble();\n      case STRING:","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java#L795-L831","documentation":"primitiveRowFieldToProto maps a Java value of an atomic FieldType into a proto AtomicTypeValue. Its switch only handles the primitive cases (BYTE, INT16, INT32, INT64, FLOAT, DOUBLE, STRING, BOOLEAN, BYTES...); any other FieldType.getTypeName() reaching it hits the default branch and throws this RuntimeException. It signals internal dispatch failure: a non-primitive type was routed to the primitive encoder.","triggerScenarios":"fieldValueToProto dispatches to primitiveRowFieldToProto with a FieldType whose TypeName is not a primitive — typically due to a missing case in the caller's switch or a schema type added in a newer Beam than the running one.","commonSituations":"Version skew with newly added type names; custom code calling fieldValueToProto with a DATETIME/DECIMAL type not covered in that Beam version; internal dispatch bug after schema evolution.","solutions":["Check the FieldType type name in the message; confirm your Beam version's supported primitive set.","Upgrade beam-sdks-java-core if the type is supported in newer versions.","Pre-convert unsupported types (e.g. DECIMAL → STRING/BYTES) before schema translation.","File/inspect a Beam issue if a legitimate primitive type reaches the default branch — likely a dispatch bug."],"exampleFix":"// before\nfieldValueToProto(FieldType.DATETIME, value); // not a handled primitive\n// after\nfieldValueToProto(FieldType.STRING, DateTimeFormat format(value)); // or upgrade Beam","handlingStrategy":"validation","validationCode":"if (!fieldType.getTypeName().isPrimitiveType()) throw new IllegalArgumentException(fieldType + \" is not primitive; primitiveRowFieldToProto cannot encode it\");","typeGuard":"boolean isEncodablePrimitive(FieldType t) { switch (t.getTypeName()) { case BYTE: case INT16: case INT32: case INT64: case FLOAT: case DOUBLE: case STRING: case BOOLEAN: case BYTES: return true; default: return false; } }","tryCatchPattern":"try { rowToProto(row); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"FieldType unexpected\")) { /* map type to supported primitive or upgrade Beam */ } else { throw e; } }","preventionTips":["Only route primitive FieldTypes to primitive encoders","Upgrade Beam when using newly added type names","Convert DATETIME/DECIMAL etc. to supported primitives for cross-version safety","Cover serialization in unit tests for every schema type you use"],"tags":["java","schema","serialization","type-mismatch"],"backgroundTag":"unsupported-enum-value","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"}