bufbuild / buf

The best way of working with Protocol Buffers.
https://buf.build
Apache License 2.0
8.49k stars 247 forks source link

Partial generation with --path when using deps the same way when working with workspace #3091

Closed igor-tsiglyar closed 1 week ago

igor-tsiglyar commented 2 weeks ago

What's up?

Hi,

I am having the proto file A importing another proto file B from a dependency. The dependent proto file B, in turn, imports other proto file C.

When using workspaces to make A -> B -> C dependency, I am able to pass only A and B to generate using --path parameter.

When using BSR modules, I am only able to use --include-imports option, which passes all 3 files A, B, and C to the plugin in gen config, which is undesirable.

Any way I can either limit import depth, or explicitly specify the files from modules to be passed into generate?

Thanks!

doriable commented 2 weeks ago

Hi, do you mind providing an example of how you've structured and configured your workspace vs. BSR modules? It is not clear to me what the contents of your workspace are and how they differ from how your BSR modules are structured.

igor-tsiglyar commented 2 weeks ago

@doriable Sure, with workspaces I have the following config in module A:

buf.work.yaml

version: v1
directories:
  - proto
  - _third_party/B

Respective config for dependent module B:

buf.work.yaml

version: v1
directories:
  - proto
  - _third_party/C

With BSR, I have buf.work.yaml replaced with a deps entry in the buf.yaml file, like:

buf.yaml

version: v1
deps:
  - <bsr>/B:<version>

When running buf generate with debug logging, I have noticed that with workspace the files from module B are treated as local:

{
  "all_with_imports": {
    "local": {
      "B.proto": [
        "C.proto"
      ],
      "A.proto": [
        "B.proto"
      ],
    }
  },
}

While when using BSR scheme, they are placed under respective dependency modules:

"all_with_imports": {
    "local": {
        "A.proto": [
            "B.proto"
        ],
    },
    "C": {
        "C.proto"
    },
    "B": {
        "B.proto": [
            "C.proto"
        ]
    }
},

This is probably why I cannot apply the --path filter to them. So the general question is: can I somehow control which BSR dependency files are passed into buf generate other than using --include-imports which would pass the whole dependency tree?

bufdev commented 2 weeks ago

@igor-tsiglyar, you're going to have to provide us a reproducible example that demonstrates the issue you'd like us to see - check out the bug template for more information on providing a reproducible example https://github.com/bufbuild/buf/issues/new?assignees=&labels=Bug&projects=&template=1-bug-report.yml

Once that is provided, we're happy to take a look!

bufdev commented 1 week ago

We weren't able to get a reproduction here, so we're going to close this issue for now. @igor-tsiglyar, if you're able to provide one, please comment with a link to the reproduction and we are more than happy to re-open!

igor-tsiglyar commented 1 week ago

@bufdev @doriable Sure, thanks! For now we decided to implement filtering at the plugin level, so we are fine with using --include-imports. Will reopen, once that changes.