Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

JS Unexpected behavior when serializing/deserializing

Đang mở
#51 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Tái hiện chuỗi setPkid/serializeBinary/deserializeBinary được hiển thị trong issue. Theo dõi setter của MyMessage và các điểm vào của quá trình tuần tự hóa/giải tuần tự hóa để xác định vị trí giá trị số trở thành chuỗi rỗng. Được xem là hoàn tất khi cách xử lý kiểu dữ liệu dự kiến có một fix được maintainer phê duyệt hoặc một quyết định được ghi lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug javascript port-fix triaged

Hello opening this issue because I've seen an unexpected behavior and want to discuss about it and see what's the best pattern

Given the following message:

message MyMessage {
    String pkid = 1;
}

If I set a number field into pkid, I'm able to retrieve it correctly. Once I serialize and then deserialize the message, the value gets coerced as an empty string:

> protoConfig.setPkid(123);
> protoConfig.getPkid();
123
> MyMessage.deserializeBinary((protoConfig.serializeBinary())).getPkid()
""

I wasn't expecting the field to be transformed silently once the message is serialized. What I would expect from order of preference:

  1. Setting the field with setPkid to crash (or a warning) because the type is not what was expected
  2. Serialization crashing (or a warning) because the type is not expected
  3. Coercing the type using toString which would set it to '123'

I understand suggested behaviors may have performance implications but I'm not sure what's the reason of current behavior because this still forces the user to do type checks before setting fields in a protobuf message when using javascript? IMO silently changing the value of a field when serializing a message is dangerous and I would aim for correctness of data first.

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

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của protocolbuffers/protobuf-javascript

Tất cả issue của protocolbuffers/protobuf-javascript

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.