Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS Protobuf Compiler Assumes Packed Arrays #2571

Closed
jsievenpiper opened this issue Jan 9, 2017 · 3 comments
Closed

JS Protobuf Compiler Assumes Packed Arrays #2571

jsievenpiper opened this issue Jan 9, 2017 · 3 comments
Assignees

Comments

@jsievenpiper
Copy link

Using protoc 3.1.. We're using the JavaNano project for our serializer, and the JS project as our deserializer.

Given the message:

message Something {
    repeated uint32 field = 1;
    // other stuff here as you see fit
}

The JS project seems to always generate code for readPackedField, even though the serializer and message are unpacked. Is this by design?

@a655329
Copy link

a655329 commented Feb 22, 2017

Hi,
I am having a related issue. After .toObject(), the repeated field in the message will be displayed as an array with an object in it. For example, the message will show:
{ field1: 0,
field2: 1,
repeated_field: [Object]}
Is there a way to call toObeject and correctly display the repeated fields? Thank you.

@acozzette
Copy link
Member

@jsievenpiper Are you using proto3? In proto3 primitive fields are packed by default, so that might explain the behavior you're seeing. However, it does look like there may be a bug here, because parsers are supposed to be able to accept the data whether it's packed or not, and it appears as though the JS parsing code can only handle the one format it's expecting.

@a655329 That sounds like it might be a separate issue; could you post an example .proto file with a proto message that has this problem?

@haberman
Copy link
Member

I think this is a duplicate of #1701.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants