cockroachdb / cockroachdb/cockroach

incorrect usage of require/assert--missing format string results in panic

Open
#101,028 2 comments 0 reactions 0 assignees View on GitHub
A-testeng-foundations A-testing C-bug quality-friday T-testeng
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Functions in `github.com/stretchr/testify` of the form,

```
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
```

_expect_ that when `len(msgAndArgs) > 1`, the first vararg is a format `string` [1]. Note the cast in [1] which results in `panic` unless the first vararg is of type `string`.

Violations to this contract have been detected in existing tests, e.g., [2]. We should consider adding a linter.

[1] https://github.com/stretchr/testify/blob/c5fc9d6b6b21ea89be8480c0dc35e2977ab988f6/assert/assertions.go#L233
[2] https://github.com/cockroachdb/cockroach/pull/95842

Jira issue: CRDB-26761

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.