buf-lint-action icon indicating copy to clipboard operation
buf-lint-action copied to clipboard

buf lint trying to lint file that doesn't exist

Open sowelipililimute opened this issue 3 years ago • 5 comments

example run: https://github.com/harmony-development/protocol/runs/4670337736?check_suite_focus=true

with a configuration like:

  lint-protos-staging:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: bufbuild/[email protected]
      - uses: bufbuild/buf-lint-action@v1
        with:
          input: 'staging'

and a file structure like

 .
├──  CMakeLists.txt
├──  FAQ.md
├──  GUIDELINES.md
├──  LICENSE
├──  README.md
├──  shell.nix
├──  stable
│  ├──  auth
│  │  └──  v1
│  │     └──  auth.proto
│  ├──  batch
│  │  └──  v1
│  │     └──  batch.proto
│  ├──  buf.yaml -> ../.buf.yaml
│  ├──  chat
│  │  └──  v1
│  │     ├──  channels.proto
│  │     ├──  chat.proto
│  │     ├──  guilds.proto
│  │     ├──  messages.proto
│  │     ├──  Permissions.md
│  │     ├──  permissions.proto
│  │     └──  stream.proto
│  ├──  CMakeLists.txt
│  ├──  emote
│  │  └──  v1
│  │     ├──  emote.proto
│  │     ├──  stream.proto
│  │     └──  types.proto
│  ├──  harmonytypes
│  │  └──  v1
│  │     └──  types.proto
│  ├──  mediaproxy
│  │  └──  v1
│  │     └──  mediaproxy.proto
│  ├──  name-resolution
│  │  ├──  example
│  │  │  ├──  go.mod
│  │  │  └──  main.go
│  │  └──  name-resolution.md
│  ├──  profile
│  │  └──  v1
│  │     ├──  appdata.proto
│  │     ├──  profile.proto
│  │     ├──  stream.proto
│  │     └──  types.proto
│  ├──  rest
│  │  └──  rest.md
│  └──  sync
│     └──  v1
│        └──  sync.proto
└──  staging
   ├──  buf.yaml -> ../.buf.yaml
   ├──  CMakeLists.txt
   └──  voice
      └──  v1
         └──  voice.proto

buf attempts to lint a file from stable, but fails because it's not in the staging directory

sowelipililimute avatar Dec 30 '21 22:12 sowelipililimute

Hi, I took a look at this by cloning the source repo and running buf lint staging locally against the head of main. It appears that the file in staging has a dependency on the file in stable, but since you are only targeting the staging directory as your input, it is unable to build because the dependency is not found. There are a few options that you can try:

  1. Running lint against the entire repository but use the ignore field in the lint configuration for your module to exclude the stable directory (docs available here: https://docs.buf.build/lint/configuration#ignore). Note that in this case, your module file will be the one you have defined here https://github.com/harmony-development/protocol/blob/main/.buf.yaml and the symlinks would be removed from the subdirectories.
  2. Separating staging and stable into two different modules. However, they would need individually defined buf.yaml configurations (instead of the symlinked configs), and a dependency would be declared on the other. You can then use a workspace file to join these dependencies. Documentation for workspaces and the configuration files are available here:
  • https://docs.buf.build/reference/workspaces
  • https://docs.buf.build/configuration/v1/buf-yaml The tour also walks through an example of setting up a workspace with two modules that depend on one another.

Hope this helps and let me know if you have any other questions!

doriable avatar Dec 30 '21 23:12 doriable

ah, i see :+1:

consider this a bug report for an unhelpful error message then, since "file not found" without further context makes it sound like buf is trying to lint something that doesn't exist instead of an import not being found

sowelipililimute avatar Dec 30 '21 23:12 sowelipililimute

"file not found" without further context

Agreed. Would something like voice/v1/voice.proto:3: import harmonytypes/v1/types.proto not found provide sufficient context?

lrewega avatar Dec 30 '21 23:12 lrewega

yes, that would be a big improvement from the status quo

sowelipililimute avatar Dec 30 '21 23:12 sowelipililimute

I've added it to an issue we already have in buf to improve the error message. Thanks for filing this!

doriable avatar Jan 04 '22 15:01 doriable

Closing as the issue above has been merged.

emcfarlane avatar Aug 01 '24 18:08 emcfarlane