map.js triggers assertion when encountering an integer-keyed map with key 0
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Bắt đầu trong js/map.js tại jspb.Map.deserializeBinary, khoảng dòng 507, và tái hiện lỗi bằng đầu vào base64 và định nghĩa PlayerData từ issue. So sánh việc giải mã các mục của map có khóa số nguyên cho các khóa 0 và 1. Được xem là hoàn tất khi dữ liệu được cung cấp được deserial hóa mà không có assertion và vẫn giữ lại mục có khóa 0.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: 3.12.2
Language: Javascript
Following is a base64 string of bytes that has been coded from C# side. I could immediately decode at C# side just fine, but it failed to decode at JS library.
CiRlZjlhNTJlNC0wZDRmLTQyNzEtOGQzYi02ODZjYWE3N2M4ZWUSClBMQVlFUjc2MTYiCUxZWERQQkFDRkocaEpRQnFhT0t3SmZVbWtyTzF5UjZ5WVBXSWMxM1oCEgBaBggBEgIIAbIBAggBwgEMCIaVuPgFEOjNpLcB
It is coming from this proto definition. Please ignore references to other unknown messages, because the problem is on just field index 11.
message PlayerData {
option (private_message) = true;
reserved 3,5,7,8, 13 to 16;
string player_id = 1;
string display_name = 2;
string short_player_id = 4;
string start_playing = 6;
string firebase_uid = 9;
map<string,MinigameProgress> minigame_progresses = 10;
//Problematic field on JS side
map<int32,CharacterConfiguration> character_configurations = 11;
int32 chilli = 12;
int32 match_count_two_players = 17;
int32 selected_character_configuration = 18;
repeated UnlockedSet unlocked_sets = 19;
repeated PermanentEvent permanent_events = 20;
map<string, google.protobuf.Timestamp> trial_timestamps = 21;
SavedConfigurations saved_configurations = 22;
repeated PurchasableFeatureId purchasable_features = 23;
google.protobuf.Timestamp start_playing_20 = 24;
}
message CharacterConfiguration{
E7.DuelOtters.Core.CharacterKind kind = 1;
string headgear_system_name = 2;
string clothing_system_name = 3;
int32 winning_dance_id = 4;
ColorMutation color_mutation = 5;
EyeMutation eye_mutation = 6;
CheekMutation cheek_mutation = 7;
ClothingKind clothing_kind = 8;
HeadgearKind headgear_kind = 9;
}
This is a ToString of real data coming from C#. Many were default, so it seems they had been efficiently stripped off.
{ "playerId": "ef9a52e4-0d4f-4271-8d3b-686caa77c8ee", "displayName": "PLAYER7616", "shortPlayerId": "LYXDPBACF", "firebaseUid": "hJQBqaOKwJfUmkrO1yR6yYPWIc13", "characterConfigurations": { "0": { }, "1": { "kind": "CharacterKind_Bomberjack" } }, "savedConfigurations": { "autoGameCenter": true }, "startPlaying20": "2020-07-14T19:41:58.384378600Z" }
When trying to deserialize in JS :
const b64 = "CiRlZjlhNTJlNC0wZDRmLTQyNzEtOGQzYi02ODZjYWE3N2M4ZWUSClBMQVlFUjc2MTYiCUxZWERQQkFDRkocaEpRQnFhT0t3SmZVbWtyTzF5UjZ5WVBXSWMxM1oCEgBaBggBEgIIAbIBAggBwgEMCIaVuPgFEOjNpLcB"
const buf = Buffer.from(b64, "base64")
PlayerData.deserializeBinary(buf)
It produces assertion failure :
Error [AssertionError]: Assertion failed
at new goog.asserts.AssertionError (/Users/Sargon/Documents/Unity Projects/Main Projects/DuelOtters/Firebase/functions/node_modules/google-protobuf/google-protobuf.js:81:876)
at Object.goog.asserts.doAssertFailure_ (/Users/Sargon/Documents/Unity Projects/Main Projects/DuelOtters/Firebase/functions/node_modules/google-protobuf/google-protobuf.js:82:257)
at Object.goog.asserts.assert [as assert] (/Users/Sargon/Documents/Unity Projects/Main Projects/DuelOtters/Firebase/functions/node_modules/google-protobuf/google-protobuf.js:83:83)
at Function.jspb.Map.deserializeBinary (/Users/Sargon/Documents/Unity Projects/Main Projects/DuelOtters/Firebase/functions/node_modules/google-protobuf/google-protobuf.js:411:241)
When compared with original source code, this assertion should be line 507 in js/map.js, jspb.Map.deserializeBinary : goog.asserts.assert(key != undefined); The key and value is going to be used in the map.set that follows so two asserts are there.
The problematic part in the data is the field index 11, map<int32,CharacterConfiguration> character_configurations = 11;
It is an int mapped to an another message. In the bytes, it has 2 members, int 0 mapped to an empty message, and int 1 mapped to a message with a bit of string data. Again, this is what they are at C#'s ToString debug :
"characterConfigurations": { "0": { }, "1": { "kind": "CharacterKind_Bomberjack" } }
By simply removing the 0 keyed entry with default message value, and add it back to be keyed with 2 instead :
"characterConfigurations": { "1": { "kind": "CharacterKind_Bomberjack" }, "2": { } }
JS is able to deserialize without triggering the assertion error. It seems like there is something with integer key at number 0. (C# could deserialize 0-keyed map in the protobuf bytes just fine)
- Ngôn ngữ chính
- JavaScript
- Star
- 471
- Fork
- 91
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của protocolbuffers/protobuf-javascript
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
protocolbuffers/protobuf-javascript#248 · 1 bình luận · 13 reaction ·
-
question
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
protocolbuffers/protobuf-javascript#222 · 9 bình luận ·
-
Why map.js sort keys?Đang mởenhancement port-fix triaged
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
protocolbuffers/protobuf-javascript#185 · 1 bình luận ·
-
enhancement port-fix triaged
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
protocolbuffers/protobuf-javascript#182 · 3 bình luận · 1 reaction ·
Tất cả issue của protocolbuffers/protobuf-javascript
Issue tương tự
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 88/100
invoiceninja/invoiceninja#13320 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type:Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
NuGet/NuGetGallery#11026 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
NoCode.vue, Task.vue: replace explicit `any` with real typesCó thể đã có người làm @prayas-bit đã nhận hôm nay. Đang mởarea/frontend good first issue kind/cooldown
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
kestra-io/kestra#20347 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Electron/Chromium StatusNotifierItem unreachable via unique bus name, tray icon never appearsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ubuntu/gnome-shell-extension-appindicator#676 · 1 bình luận ·
-
first-Agent inherits Docker TLS settings for its recorded Unix socketCó thể đã có người làm @ericcaiwx-star đã nhận hôm nay. Đang mởclawsweeper:bulk-filed clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
openclaw/openclaw-enterprise#1337 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày