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

Extension fields appear to be ignored #103

Open
nivekastoreth opened this issue Jun 8, 2022 · 1 comment
Open

Extension fields appear to be ignored #103

nivekastoreth opened this issue Jun 8, 2022 · 1 comment

Comments

@nivekastoreth
Copy link

It appears that extension fields are not parsed/emitted even though they are part of the underlying FDSet. This appears to be the case both for direct extensions and message extensions (which is where I first ran into this)


To replicate:

foo.proto

syntax = "proto2";

message Foo {
  required int32 foo = 1;
  extensions 100 to 199;
}

message BazExt {
  optional int32 baz = 1;
}

extend Foo {
  optional int32 bar = 125;
  optional BazExt baz_ext = 126;
}

foo.message

foo: 1
[bar]: 2
[baz_ext] {
  baz: 3
}

reproduce

$ protoc -I . foo.proto --encode=Foo < foo.message | protoc --decode_raw
1: 1
125: 2
126 {
  1: 3
}

$ protoc -I . foo.proto --encode=Foo < foo.message | protoc -I . foo.proto --decode=Foo
foo: 1
[bar]: 2
[baz_ext] {
  baz: 3
}

$ protoc -I . foo.proto -o foo.fdset

$ PROTOC_INCLUDE="$PB_FDSET_DIR" pq --protofile "$PB_FDSET_DIR/descriptor.proto" --msgtype google.protobuf.FileDescriptorSet < foo.fdset | jq -c '.file[].extension[]'
{"name":"bar","extendee":".Foo","number":125,"label":"LABEL_OPTIONAL","type":"TYPE_INT32","type_name":null,"default_value":null,"options":null,"oneof_index":null,"json_name":"bar","proto3_optional":null}
{"name":"baz_ext","extendee":".Foo","number":126,"label":"LABEL_OPTIONAL","type":"TYPE_MESSAGE","type_name":".BazExt","default_value":null,"options":null,"oneof_index":null,"json_name":"bazExt","proto3_optional":null}

$ pq --fdsetfile foo.fdset --msgtype Foo < <(protoc -I . foo.proto --encode=Foo < foo.message)
{
  "foo": 1
}
@sevagh
Copy link
Owner

sevagh commented Jun 3, 2024

Sorry for late reply: I haven't worked on pq or protobuf in a while. If you'd feel like trying to submit a fix for this, I'd be happy to review a PR.

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

2 participants