cockroachdb / cockroachdb/cockroach

*: add a linter for errors that are just logged and swallowed

Open
#146,570 1 comment 0 reactions 0 assignees View on GitHub
A-disaster-recovery A-linters C-enhancement O-postmortem P-3 T-disaster-recovery
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Sometimes it is correct to log an error and not return it higher up in the call stack. But other times it is not correct, and the consequences of doing so can be severe. One example of this is covered in this post-mortem on bulk ingestion error handling: https://cockroachlabs.atlassian.net/wiki/x/EoB5DgE. The corresponding issue is https://github.com/cockroachdb/cockroach/issues/144650.

It can be pretty easy to forget to propagate an error simply because plumbing the error requires additional refactors. We already have a `https://github.com/cockroachdb/cockroach/issues/144650` linter that checks if an error is completely ignored: https://github.com/cockroachdb/cockroach/blob/c68c559859be738efead9971f5e11f62a8c69d06/pkg/testutils/lint/passes/returnerrcheck/returnerrcheck.go#L6-L9

We should enhance that or add a new linter that can also detect if an error is just logged and not returned. Sometimes that is correct behavior, so the linter should have an opt-out directive, like the existing approach of using `//nolint:returnerrcheck`.

Jira issue: CRDB-50600

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.