protocolbuffers / protocolbuffers/protobuf-javascript

Oneof toObject loses case

Open
#33 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug javascript port-fix triaged
Dominant language
JavaScript
Stars
471
Forks
91
Avg merge
3h 57m
Merged PRs (30d)
2

Description

What version of protobuf and what language are you using?
Version: master/v3.6.0/v3.5.0 etc.
Language: Javascript

What operating system Linux, Windows and version?

What runtime / compiler are you using (e.g., python version or gcc version)

What did you do?
Steps to reproduce the behavior:
generated classes and methods via protoc-grpc-web result in oneof losing its case when converted to a plain object by toObject()
See https://github.com/grpc/grpc-web/issues/675 for details

What did you expect to see
The result object to only have one defined property for the oneof case

What did you see instead?
All of the oneof cases are generated in the result plain object with their type default values

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the protoc-grpc-web generated classes and their toObject() conversion, using the behavior described in issue #675 as the reproduction reference. Done means a plain object contains only the defined property for the active oneof case, rather than default-valued properties for every case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.