bazel-contrib / bazel-contrib/vscode-bazel

Go to Definition treats go_proto_library.importpath as Bazel label and runs invalid query

Open
#622 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
296
Forks
108
Avg merge
3d 22h
Merged PRs (30d)
5

Description

When I trigger Go to Definition on a quoted importpath value in a BUILD file, the extension appears to treat that value as a Bazel label and runs bazel query on it.

Example (sanitized):

```
go_proto_library(
name = "metrics_go_proto",
importpath = "github.com/example-org/example-repo/protos/vision/metrics_go_proto",
protos = [":metrics_proto"],
)
```

Observed query (sanitized):

```
bazel query //vision/stereo:github.com/example-org/example-repo/protos/vision/metrics_go_proto
```

Observed error:

```
Bazel query failed with code 7
ERROR: no such target '//vision/stereo:github.com/example-org/example-repo/protos/vision/metrics_go_proto'
```

Expected behavior:

- `importpath` should not be interpreted as a Bazel label.
- Go to Definition should only query valid labels (for example `//...`, `@repo//...`, `:...`) or skip non-label attributes like `importpath`.

Notes:

The actual target label resolves fine (for example //vision/stereo:metrics_go_proto).
This looks like extension-side label parsing/heuristic behavior, not a rules_go target definition issue.

Contributor guide

Open the contributing guide

Research direction

Start from the Go to Definition handling for quoted attributes in BUILD files and reproduce the issue with the provided go_proto_library example. Trace the generated bazel query and ensure importpath is skipped while valid labels such as //vision/stereo:metrics_go_proto remain queryable; done when the invalid query is no longer run.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.