Skip to content

Extension fields appear to be ignored #103

@nivekastoreth

Description

@nivekastoreth

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions