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

Parser Bug: incorrect namespacing on circular top level messages #127

Open
rwstauner opened this issue Aug 16, 2024 · 0 comments
Open

Parser Bug: incorrect namespacing on circular top level messages #127

rwstauner opened this issue Aug 16, 2024 · 0 comments

Comments

@rwstauner
Copy link
Contributor

With a new test in test/parser_compatibility_test.rb like

    def test_circular_messages
      ours, theirs = parse_string(<<-EOPROTO)
syntax = "proto3";

message Circular {
  CircularValue circ = 1;
}

message CircularValue {
  oneof kind {
    Circular circ = 1;
    CircularValue val = 2;
  }
}
      EOPROTO

      assert_same_tree theirs, ours
    end

I get this failure:

  1) Failure:
ProtoBoeuf::ParserCompatibilityTest#test_circular_messages [test/parser_compatibility_test.rb:358]:
Expected: ".CircularValue"
  Actual: ".Circular.CircularValue"

This is why we switched to generating our well-known types with protoc (#125)
because using our parser on struct.proto was generating a reference to Struct::Value but creating the module as Value.

Changing the order of these two messages changes the namespace it wants to put on the types:

message Struct {
// Unordered map of dynamically typed values.
map<string, Value> fields = 1;
}
// `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of these
// variants. Absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
message Value {
// The kind of value.
oneof kind {
// Represents a null value.
NullValue null_value = 1;
// Represents a double value.
double number_value = 2;
// Represents a string value.
string string_value = 3;
// Represents a boolean value.
bool bool_value = 4;
// Represents a structured value.
Struct struct_value = 5;
// Represents a repeated `Value`.
ListValue list_value = 6;
}
}

It may be that the parser is trying to qualify the field type too early and we may need to delay that until we've seen all the top-level messages in the file.

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