Skip to content

Reporting bugs - #159

Merged
fredbi merged 7 commits into
go-openapi:masterfrom
fredbi:reporting-bugs
Aug 23, 2026
Merged

Reporting bugs#159
fredbi merged 7 commits into
go-openapi:masterfrom
fredbi:reporting-bugs

Conversation

@fredbi

@fredbi fredbi commented Aug 23, 2026

Copy link
Copy Markdown
Member

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

fredbi and others added 7 commits August 23, 2026 19:49
When the container is a string, containsElement rendered the element with
reflect.Value.String(). That returns a placeholder for any kind other than a
string, so Contains(t, "hello", 'e') compared "hello" against the literal
"<int32 Value>" and failed, naming a type where the character should be.

stringContainsElement now dispatches on the element instead: strings.Contains
for a string, strings.ContainsRune for a rune, strings.IndexByte for a byte,
and the reflect fallback only for a defined string type such as
`type Doc string`. Any other kind cannot occur in a string and still reports
"does not contain".

Left alone: a needle that is not valid UTF-8 still matches on byte boundaries,
so Contains(t, "é", "\xa9") stays true, since "\xa9" is the second byte of "é".
Upstream converts both operands to []rune to prevent that, which costs an
allocation on every string Contains to reject a deliberately malformed needle.

reference: github.com/stretchr#1908

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Empty rendered the value with %v, so a string of whitespace left nothing on
screen: Empty(t, "  ") reported `Should be empty, but was   `, which reads as a
message that lost its value. NotEmpty had the same problem with the empty
string.

truncatingValue picks %q for anything of string kind, aliased string types
included, and keeps %v for everything else. NotEmpty now goes through it too,
so its value is truncated at maxMessageSize like every other failure message
instead of being printed whole.

reference: github.com/stretchr#1874
reference: github.com/stretchr#1875

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
The per-element call passed "at index %d" as the message, which does not add
the index to what the caller wrote, it replaces it. A caller who passed
InEpsilonSlice(t, want, got, eps, "checking %s", "widths") saw the index and
never saw "checking widths".

withContext joins the two: the positional context, then the caller's message
rendered through messageFromMsgAndArgs. With nothing from the caller it yields
the context alone, so a bare call still names the element that failed.

reference: github.com/stretchr#1931
reference: github.com/stretchr#1899

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
A missing key was already reported by name, but a key present in both maps
whose values are further apart than delta was not: the failure came from
InDelta, which sees the two values and not the key they were read under. On a
map of any size that leaves the reader to work out which entry failed.

The per-key call now carries "at key <k>" through withContext, the same way
InEpsilonSlice carries its index, so the caller's own message survives too.

reference: github.com/stretchr#1898

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
The per-element call handed InDelta the actual value first and the expected
one second, so a failure read "Max difference between 9 and 2" for
InDeltaSlice(t, []float64{2}, []float64{9}, 0.5) — the two named the wrong way
round. The verdict was never affected, since a delta is symmetric, which is why
only a message test catches it.

Inherited from upstream, where the same two arguments are still swapped. No
upstream issue covers it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
EqualValues(t, int64(-1), uint64(math.MaxUint64)) passed. ObjectsAreEqualValues
compares by converting one operand to the other's type, and converting a
negative signed integer to an unsigned one wraps it to exactly the value it is
being compared against.

Converting the smaller type to the larger one, which is what keeps
EqualValues(t, int(270), int8(14)) false, does not help here: int8(-1) wraps to
uint64(math.MaxUint64) just as int64(-1) does. Four shapes passed wrongly —
int64/uint64, int8/uint64, int/uint, and either argument order.

A signed and an unsigned integer now compare by value instead: a negative
signed value equals no unsigned value, and otherwise both fit in a uint64.
Floats are untouched, and mixed signedness still compares equal when the values
are, as in EqualValues(t, uint8(200), int64(200)).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
The August sweep of stretchr/testify turned up four reports describing bugs we
had inherited. Each now has a row in the implemented table saying what we
adopted and what we left alone, and stretchr#1942 joins stretchr#1940 as the PR behind
ErrorNotContains.

stretchr#1776 goes in as informational: upstream's generated require documentation
lists a bool return that the functions do not have, the same defect our own API
pages carried until the signature tables were corrected. Nothing to adopt, but
worth recording that both projects found it independently.

Two more bugs surfaced while checking those four, neither of them reported
upstream, so neither gets a row: InDeltaSlice named expected and actual the
wrong way round in its failures, and EqualValues compared a negative signed
integer equal to a large unsigned one.

Also in this file: the review-frequency line was three months stale, [stretchr#1937]
was referenced with no link definition and rendered as literal text, three
definitions were duplicated, and the summary counts are recounted from the
tables.

reference: github.com/stretchr#1776
reference: github.com/stretchr#1874
reference: github.com/stretchr#1875
reference: github.com/stretchr#1898
reference: github.com/stretchr#1899
reference: github.com/stretchr#1908
reference: github.com/stretchr#1931
reference: github.com/stretchr#1940
reference: github.com/stretchr#1942

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.71%. Comparing base (f118d27) to head (fcd4e8a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #159      +/-   ##
==========================================
+ Coverage   93.68%   93.71%   +0.02%     
==========================================
  Files         106      106              
  Lines       13842    13883      +41     
==========================================
+ Hits        12968    13010      +42     
+ Misses        867      866       -1     
  Partials        7        7              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@fredbi
fredbi merged commit 2b009bf into go-openapi:master Aug 23, 2026
25 checks passed
@fredbi
fredbi deleted the reporting-bugs branch August 23, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant