buf lint trying to lint file that doesn't exist
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
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:
- Running lint against the entire repository but use the
ignorefield in the lint configuration for your module to exclude thestabledirectory (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. - Separating
stagingandstableinto two different modules. However, they would need individually definedbuf.yamlconfigurations (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!
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
"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?
yes, that would be a big improvement from the status quo
I've added it to an issue we already have in buf to improve the error message. Thanks for filing this!
Closing as the issue above has been merged.