File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -584,10 +584,16 @@ Message<google_firestore_v1_Value> BundleSerializer::DecodeValue(
584
584
585
585
Message<google_firestore_v1_MapValue> BundleSerializer::DecodeMapValue (
586
586
JsonReader& reader, const json& map_json) const {
587
- if (!map_json.is_object () || !map_json. contains ( " fields " ) ) {
588
- reader.Fail (" mapValue is not a valid map " );
587
+ if (!map_json.is_object ()) {
588
+ reader.Fail (" mapValue is not a valid object " );
589
589
return {};
590
590
}
591
+
592
+ // Empty map doesn't have `fields` field.
593
+ if (!map_json.contains (" fields" )) {
594
+ return {};
595
+ }
596
+
591
597
const auto & fields = map_json.at (" fields" );
592
598
if (!fields.is_object ()) {
593
599
reader.Fail (" mapValue's 'field' is not a valid map" );
Original file line number Diff line number Diff line change @@ -231,10 +231,13 @@ class BundleReaderTest : public ::testing::Test {
231
231
value3.set_null_value (google::protobuf::NULL_VALUE);
232
232
ProtoValue value4;
233
233
value4.mutable_array_value ();
234
+ ProtoValue value5;
235
+ value5.mutable_map_value ();
234
236
document.mutable_fields ()->insert ({" \0\ud7ff\ue000\uffff\" " , value1});
235
237
document.mutable_fields ()->insert ({" \" (╯°□°)╯︵ ┻━┻\" " , value2});
236
238
document.mutable_fields ()->insert ({" nValue" , value3});
237
239
document.mutable_fields ()->insert ({" emptyArray" , value4});
240
+ document.mutable_fields ()->insert ({" emptyMap" , value5});
238
241
239
242
return document;
240
243
}
You can’t perform that action at this time.
0 commit comments