google / google/protobuf.dart

Adding a field with a default value

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

Description

Hi. When adding a test field with a default value (false). Binary view this field is added.
This behavior is different from the behavior in java.
https://developers.google.com/protocol-buffers/docs/proto3#default
Example:
**{"test": null}**
dart
[186, 6, 0]
java
[-70, 6, 0]
That's right, expected result.

**{"test": true}**
dart
[186, 6, 2, 40, 1]
java
[-70, 6, 2, 40, 1]
That's right, expected result.

**{"test": false}**
dart
[186, 6, **2, 40, 0**]
java
[-70, 6, 0]
in java the correct result in dart is not

Contributor guide

Open the contributing guide

Research direction

Start with the proto3 default-value documentation and the supplied Dart and Java binary examples. Compare how a false value is encoded when the field has a default, then verify that Dart produces the same result as Java for null, true, and false cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.