Fix map decoding when key or value fields are missing (#745)

Map fields are encoded as repeated message fields where the message
field 1 is the key and 2 is the value.

In proto syntax, a map field like

    map<int32, MyMessage> map_field = 1;

is encoded as if it was

    repeated MapFieldEntry map_field = 1;

where

    message MapFieldEntry {
        optional int32 key = 1;
        optional MyMessage value = 2;
    }

Since map entries are ordinary messages, it's possible for a map entry
to have no key or value fields.

This PR updates map decoding to handle missing key and value fields.
Three tests added for (1) missing key field (2) missing value field (3)
missing key and value fields (entry message has 0 length prefix).

Fixes #719
5 files changed
tree: 52afdafae2f115dfb353fd3c7dbd0dfbddff1661
  1. .github/
  2. api_benchmark/
  3. benchmarks/
  4. protobuf/
  5. protoc_plugin/
  6. tool/
  7. .gitignore
  8. AUTHORS
  9. LICENSE
  10. mono_repo.yaml
  11. README.md
README.md

CI status

Protobuf support for Dart

Protocol Buffers (protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.

This repository is home to packages related to protobuf for Dart.

PackageDescriptionPublished Version
protobufA support library for the generated codepub package
protoc_pluginA Dart back-end for the protoc compilerpub package
api_benchmarkBenchmarking for various API calls
query_benchmarkBenchmark for encoding and decoding of a “real-world” protobuf