File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -339,6 +339,9 @@ def is_map(
339
339
) -> bool :
340
340
"""True if proto_field_obj is a map, otherwise False."""
341
341
if proto_field_obj .type == FieldDescriptorProtoType .TYPE_MESSAGE :
342
+ if not hasattr (parent_message , "nested_type" ):
343
+ return False
344
+
342
345
# This might be a map...
343
346
message_type = proto_field_obj .type_name .split ("." ).pop ().lower ()
344
347
map_entry = f"{ proto_field_obj .name .replace ('_' , '' ).lower ()} entry"
Original file line number Diff line number Diff line change
1
+ syntax = "proto3" ;
2
+
3
+ package entry ;
4
+
5
+ // This is a minimal example of a repeated message field that caused issues when
6
+ // checking whether a message is a map.
7
+ //
8
+ // During the check wheter a field is a "map", the string "entry" is added to
9
+ // the field name, checked against the type name and then further checks are
10
+ // made against the nested type of a parent message. In this edge-case, the
11
+ // first check would pass even though it shouldn't and that would cause an
12
+ // error because the parent type does not have a "nested_type" attribute.
13
+
14
+ message Test {
15
+ repeated ExportEntry export = 1 ;
16
+ }
17
+
18
+ message ExportEntry {
19
+ string name = 1 ;
20
+ }
You can’t perform that action at this time.
0 commit comments