Skip to content

Error when deserializing GoLang implicitly packed repeated field #166

Closed
@Santalov

Description

@Santalov

Suppose you have a proto like this

message Repeated {
  repeated int64 implicitly_packed_options = 4 [jstype = JS_NUMBER]; // field options should have no effect
}

And protoc-gen-ts does not deserialize this message when it is serialized with GoLang. Deserialization fails with Assertion error.

protoc-gen-ts generates deserialize method like this

        static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Repeated {
            const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Repeated();
            while (reader.nextField()) {
                if (reader.isEndGroup())
                    break;
                switch (reader.getFieldNumber()) {
                    case 4:
                         pb_1.Message.addToRepeatedField(message, 4, reader.readInt64());
                        break;
                    default: reader.skipField();
                }
            }
            return message;
        }

Looks like the field is trusted as a packed = false field, while there is no such field option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions