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

Fixing client serialization bugs #402

Merged
merged 4 commits into from
Jan 14, 2025

Conversation

jasonmreding
Copy link
Collaborator

@jasonmreding jasonmreding commented Jan 9, 2025

Description

This addresses a number of client serialization issues around sparse enums and oneof fields.

  • In the case of sparse enums, we failed to translate back from the proto enum value to the LV enum value. This would result in the LV enum value always showing the last enum value.
  • For oneof fields we failed to assign the selected_index field in the cluster which made it look like no fields from the oneof were ever set when reading response data on the client.
  • This also fixes an issue where we sometimes were serializing the selected_index field across the wire which would end up getting captured in the unknown fields in the message on the other end.
  • Messages containing more than one oneof field were not getting the selected_index field set correctly on their class cluster.

#396
#343

Implementation

Most of these were only issues with the LVMessageEfficient derived class which I believe is only used for unary calls from the client. Otherwise, we end up using the ClusterDataCopier methods which already handled this.

  • LVMessage now tracks data for which field of a oneof is selected. This data structure is updated when parsing a message. It is also updated by ClusterDataCopier when constructing a LVMessage from its cluster representation.
  • LVMessageEfficient now assigns the selected_index field in the class cluster for a oneof during PostInteralParseAction using the new data structure added to LVMessage.
  • LVMessageEfficient now has a hand written override for ParseEnum which translates from enum values from a proto file (which can be "sparse" or non-sequential) to the LV assigned enum value for the cluster since LV only supports sequential enum values.
  • When assigning selected_index field values for the class cluster, we now iterate over _elements instead of _mappedElements. Since we use -1 as the field number for all selected_index fields, there will only ever be one entry in _mappedElements. This obviously doesn't work if the message has more than one oneof field.

Testing

Manually tested generation of both the client and the server using proto APIs that included nested messages, enums, and oneof fields. Tested both Win32 and Win64 using LV 2019 and LV 2024.

…ds. Also fixed an issue where we sometimes were serializing the selected_index field across the wire which would end up getting captured in the unknown fields.
src/cluster_copier.cc Outdated Show resolved Hide resolved
src/cluster_copier.cc Outdated Show resolved Hide resolved
@jasonmreding jasonmreding requested a review from bkeryan January 9, 2025 00:34
* master:
  Run grpc code generation in a private application context (#401)
src/lv_message.cc Outdated Show resolved Hide resolved
src/cluster_copier.cc Outdated Show resolved Hide resolved
src/cluster_copier.cc Outdated Show resolved Hide resolved
src/lv_message_efficient.h Outdated Show resolved Hide resolved
src/lv_message_efficient.h Outdated Show resolved Hide resolved
src/lv_message_efficient.cc Outdated Show resolved Hide resolved
src/lv_message_efficient.cc Outdated Show resolved Hide resolved
@jasonmreding jasonmreding requested a review from bkeryan January 14, 2025 01:16
@jasonmreding jasonmreding merged commit 02951e0 into master Jan 14, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants