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

package resolution of protox is less strict than protoc #82

Closed
tardyp opened this issue Aug 26, 2024 · 1 comment · Fixed by #84 or andrewhickman/prost-reflect#126
Closed

package resolution of protox is less strict than protoc #82

tardyp opened this issue Aug 26, 2024 · 1 comment · Fixed by #84 or andrewhickman/prost-reflect#126

Comments

@tardyp
Copy link
Contributor

tardyp commented Aug 26, 2024

on following test repository:
https://github.com/tardyp/protox_resolution_issue

  • annotations.proto
syntax = "proto3";

package foo;
import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
  string owner = 50000;
}

message Foo {
  string field = 1;
}
  • foo.proto
syntax = "proto3";

// note that this package starts with com.foo, while the other package starts with foo directly
package com.foo.bar;

import "annotations.proto";

message Bar {
    option (foo.owner) = "com.foo.bar";
    string field = 1;
    foo.Foo field2 = 2;
}

protoc.sh will give error

foo.proto:10:5: "foo.Foo" is resolved to "com.foo.Foo", which is not defined. The innermost scope is searched first in name resolution. Consider using a leading '.'(i.e., ".foo.Foo") to start from the outermost scope.

I created a protoxyc.py and build.rs using protox and protobuf_codegen

The three will happily accept the incorrect protobuf files.

@andrewhickman
Copy link
Owner

Nice find, thanks for the report (and the fix!)

andrewhickman added a commit that referenced this issue Sep 9, 2024
* test for name resolution shadowing

Fix: #82

* Update to prost-reflect 0.14.2

---------

Co-authored-by: Andrew Hickman <andrew.hickman1@sky.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants