From f2db138906ec9f16c13748bb7b117079b6259676 Mon Sep 17 00:00:00 2001 From: Victor Chudnovsky Date: Thu, 10 Oct 2024 10:28:50 -0700 Subject: [PATCH] alert for unexpected format values when type==ANY --- .../proto3/DocumentToProtoConverter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/cloud/discotoproto3converter/proto3/DocumentToProtoConverter.java b/src/main/java/com/google/cloud/discotoproto3converter/proto3/DocumentToProtoConverter.java index 2dfeb29..4c3cd87 100644 --- a/src/main/java/com/google/cloud/discotoproto3converter/proto3/DocumentToProtoConverter.java +++ b/src/main/java/com/google/cloud/discotoproto3converter/proto3/DocumentToProtoConverter.java @@ -545,10 +545,16 @@ private Field schemaToField(Schema sch, boolean optional, String debugPreviousPa valueType = Message.PRIMITIVES.get("google.protobuf.Value"); this.usesStructProto = true; break; - case ANY: + case EMPTY: // intentional fall-through - default: + case ANY: valueType = Message.PRIMITIVES.get("google.protobuf.Any"); + break; + default: + throw new IllegalStateException( + String.format( + "unexpected 'format' value ('%s') when processing ANY type in schema %s", + sch.format().toString(), debugCurrentPath)); } break; case ARRAY: