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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing valuesOptions in fromJSON parser function #1961

Open
dobrac opened this issue Jan 13, 2024 · 0 comments
Open

Missing valuesOptions in fromJSON parser function #1961

dobrac opened this issue Jan 13, 2024 · 0 comments

Comments

@dobrac
Copy link

dobrac commented Jan 13, 2024

Hi! 馃憢

I've found out the "valuesOptions" option in Enum class is missing when parsed from the JSON.

Reproduction:

  • Create .proto file containing an enum with the valuesOptions
  • Generate JSON from this .proto file
  • Parse the generated JSON back
  • Try to access the valuesOptions field in that enum

The following code change should fix it:

diff --git a/node_modules/protobufjs/src/enum.js b/node_modules/protobufjs/src/enum.js
index 1c01620..730b8e4 100644
--- a/node_modules/protobufjs/src/enum.js
+++ b/node_modules/protobufjs/src/enum.js
@@ -87,7 +87,7 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
  * @throws {TypeError} If arguments are invalid
  */
 Enum.fromJSON = function fromJSON(name, json) {
-    var enm = new Enum(name, json.values, json.options, json.comment, json.comments);
+    var enm = new Enum(name, json.values, json.options, json.comment, json.comments, json.valuesOptions);
     enm.reserved = json.reserved;
     return enm;
 };

This issue body was partially generated by patch-package.

dobrac added a commit to dobrac/protobuf.js that referenced this issue Apr 8, 2024
I've found out that the "valuesOptions" option in the Enum class is missing when parsed from the JSON.

This PR should fix the issue: protobufjs#1961
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

1 participant