Skip to content

Parsing JSON protobufs produced from textproto ObjectValue fails #22989

@HoneyryderChuck

Description

@HoneyryderChuck

What version of protobuf and what language are you using?
Version: 4.31.1 (ruby protobuf gem version)
Language: Ruby

What operating system (Linux, Windows, ...) and version?

Don't think this makes a difference, but I'm on a MacOS Sequoia 15.5 .

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

> ruby -v
ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [x86_64-darwin24]
> clang -v
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: x86_64-apple-darwin24.5.0
Thread model: posix

What did you do?

Described below.

What did you expect to see

I maintain cel-ruby, which uses the conformance tests layer provided in the cel-spec repo. The conformance tests are unfortunately provided in the textproto format; it's unfortunate because it seems that its usage is slowly being deprecated, and in my specific case, where I use the ruby protobuf lib, there isn't a textproto parser (I have an open issue to add it, although I don't have hopes it's going to be prioritized). So in order to make this work, I maintain a simple python script to parse the textproto files and dump them in json format (which the ruby protobuf lib can parse).

There's an edge case which fails under this pipeline though, specifically this type of test, where the binding is defined as an object value. the python layer is able to parse it, and when I inspect its value in the console, I get the following:

>>> message.section[0].test[0].bindings
{'msg': value {
  object_value {
    type_url: "type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes"
    value: "\300>*"
  }
}
}

This value then gets dumped in JSON as:

# ...
"bindings": {
            "msg": {
              "value": {
                "objectValue": {
                  "@type": "type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes",
                  "[cel.expr.conformance.proto2.int32_ext]": 42
                }
              }
            }
          }
# ...

And the respective ruby proto stub can't decode it:

Cel::Expr::Conformance::Test::SimpleTestFile.decode_json(File.binread("path/to/json_generated_by_py_script.json")) #=> Error occurred during parsing: Error parsing JSON @952:61: No such field: [cel.expr.conformance.proto2.int32_ext] (Google::Protobuf::ParseError)

This seems to a limitation in the json decoder.

What did you see instead?

I'd expect it to be evaluated to a Value{object_value: ...}.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions