Skip to content

missing {} after printing option #583

@japersik

Description

@japersik

Hi,
I'm facing a problem that I don't know how to fix..
when parsing and printing the same file containing option, the file becomes invalid

A simple example:

syntax = "proto2";
package pkg;
option go_package = "some.pkg";
import "google/protobuf/descriptor.proto";
message Options {
    optional bool some_option_value = 1;
}
extend google.protobuf.MessageOptions {
    optional Options my_some_option = 11964;
}
message SomeMessage {
    option (.pkg.my_some_option) = {some_option_value : true};
}

I'm using ParseFilesButDoNotLink(...) because the extension may be unknown

after parsing and printing this file, I got this

syntax = "proto2";

package pkg;

import "google/protobuf/descriptor.proto";

option go_package = "some.pkg";

message Options {
  optional bool some_option_value = 1;
}

message SomeMessage {
  option (.pkg.my_some_option) = some_option_value : true;
}

extend .google.protobuf.MessageOptions {
  optional .pkg.Options my_some_option = 11964;
}

option option (.pkg.my_some_option) = some_option_value : true; is invalid cause curly braces are missing

I tried to use bufbuild compiller instead of protoparse, but I got the same result

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