bazelbuild / bazelbuild/bazel

Allow rule sets to contribute suggested fix for undefined starlark symbol

Open
#7,163 7 comments 0 reactions 0 assignees View on GitHub
bad error messaging not stale P4 team-ExternalDeps type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

If my BUILD file uses `ts_library` but didn't have a `load` statement, I get
```
INFO: Invocation ID: fed413d4-6f15-4e1e-aab2-f026332cde62
ERROR: C:/users/alexeagle/projects/try_bazel/BUILD.bazel:1:1: name 'ts_library' is not defined (did you mean 'py_library'?)
ERROR: error loading package '': Package '' contains errors
```

First, the last line here is spam.
Second, it suggests `py_library` which is strange to me as a novice user: I don't have any Python and didn't configure Bazel to use python so why am I getting this?
Angular users will be put off by the idea that Python is the preferred language in Bazel.

Ideally we should allow rules_typescript to contribute a helper, so that Bazel would suggest adding the correct `load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")`

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with a BUILD.bazel file that uses ts_library without a load statement, then trace Bazel's undefined-symbol suggestion handling and how an external rule set could contribute suggestions. Done means the diagnostic can suggest the exact rules_typescript load statement, no longer recommends py_library misleadingly, and removes the final spam line.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.