Skip to content

Bug using new syntax "edition" #184

Description

@glats

With

services:
  grpc:
    image: tkpd/gripmock
    ports:
      - 4770:4770
      - 4771:4771
    volumes:
      - "./proto:/proto"
    command: /proto/cache.proto

Using

edition = "2023";

import "google/protobuf/empty.proto";

option go_package = "server/internal/cache";

service Cache {
  rpc Reset(ResetCache) returns (google.protobuf.Empty) {}
}

enum CacheType {
  UNKNOWN = 0;
  ALL = 1;
}

message ResetCache {
  CacheType type = 1;
}

Show the following error:

Starting GripMock
Serving stub admin on http://:4771
cache.proto:32:8: Option "go_package" unknown. Ensure that your proto definition file imports the proto which defines the option.
cache.proto:22:8: Option "go_package" unknown. Ensure that your proto definition file imports the proto which defines the option.
cache.proto:14:8: Option "go_package" unknown. Ensure that your proto definition file imports the proto which defines the option.
cache.proto:4:8: Option "go_package" was already set.
2025/07/29 23:20:58 Fail on protoc exit status 1

As i saw this happens because i'm using the new edition tag instead the syntax adn the script inside the projects look up for it

https://github.com/tokopedia/gripmock/blob/master/scripts/fix_gopackage.sh#L45

which generates:

edition = "2023";
option go_package = "github.com/tokopedia/gripmock/protogen/proto";

option go_package = "github.com/tokopedia/gripmock/protogen/proto";
import "google/protobuf/empty.proto";
option go_package = "github.com/tokopedia/gripmock/protogen/proto";

option go_package = "github.com/tokopedia/gripmock/protogen/proto";

option go_package = "github.com/tokopedia/gripmock/protogen/proto";

option go_package = "github.com/tokopedia/gripmock/protogen/proto";
service Cache {
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
  rpc Reset(ResetCache) returns (google.protobuf.Empty) {}
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
}
option go_package = "github.com/tokopedia/gripmock/protogen/proto";

option go_package = "github.com/tokopedia/gripmock/protogen/proto";
enum CacheType {
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
  UNKNOWN = 0;
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
  ALL = 1;
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
}
option go_package = "github.com/tokopedia/gripmock/protogen/proto";

option go_package = "github.com/tokopedia/gripmock/protogen/proto";
message ResetCache {
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
  CacheType type = 1;
option go_package = "github.com/tokopedia/gripmock/protogen/proto";
}
option go_package = "github.com/tokopedia/gripmock/protogen/proto";

if i use both i get:

edition = "2023";
syntax = "proto3";

import "google/protobuf/empty.proto";

option go_package = "server/internal/cache";

service Cache {
  rpc Reset(ResetCache) returns (google.protobuf.Empty) {}
}

enum CacheType {
  UNKNOWN = 0;
  ALL = 1;
}

message ResetCache {
  CacheType type = 1;
}
Starting GripMock
Serving stub admin on http://0.0.0.0:4771
cache.proto:2:1: Expected top-level statement (e.g. "message").
2025/07/30 01:11:33 Fail on protoc exit status 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions