google / google/protobuf.dart

Unknown enum values in map

Open
#538 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
Dart
Stars
572
Forks
196
Avg merge
1h 59m
Merged PRs (30d)
2

Description

Hello,

Right now, if we have some protobuf definition like this:

```protobuf
enum Value {
VALUE_INVALID = 0;
VALUE_A = 1;
VALUE_B = 2;
}

message Message {
map values = 1;
}
```

The protobuf library will parse it correctly.
But now let's suppose we add another value to the enum.

```protobuf
enum Value {
VALUE_INVALID = 0;
VALUE_A = 1;
VALUE_B = 2;
VALUE_C = 3;
}

message Message {
map values = 1;
}
```
Clients generated with the first version (without `VALUE_C`) crashes when parsing a message containing this new value.
And we end up with "DATA_LOSS" when using the grpc lib.

Reading the spec and to match what is happening for enum values outside of maps, I think we should use the default value when we find some unknown enum value in a map. Or we could do the same as what the library is currently doing for lists => skip the value.

This might be related to #508 and #536 but is also happening without using null safety.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.