cockroachdb / cockroachdb/cockroach

build: rewrite the "errors" and "fmt" imports in certain go dependencies

Open
#104,014 0 comments 0 reactions 0 assignees View on GitHub
A-build-system C-enhancement T-dev-inf
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Is your feature request related to a problem? Please describe.**

We would like to gain more insight into errors produced by our upstream dependencies such as grpc.
In particular:
- we'd like them to more precisely annotate PII vs non-PII bits in error messages.
- we'd like to include stack traces.

In short, we'd like them to be enhanced via the crdb errors library.

Currently, doing so requires _forking_ the upstream dependencies and manually rewrite calls to `errors.New` and `fmt.Errorf` to reuse the crdb errors' library `errors.New` and `errors.Newf` (for example in #103886). This is error-prone, and creates a maintainance burden every time we want to upgrade the dependency.

**Describe the solution you'd like**

We would like to explore a build-time automatic rewrite of the import path in some of our dependencies, e.g. grpc.

The rewrite could occur in the bazel sandbox, either on the go source files or perhaps by customizing the go linker to add some function path rewrite rules.

**Note: we probably want to redirect the calls to certain functions, not entire packages at a time.**

Jira issue: CRDB-28311

Epic CRDB-21266

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.