Skip to content

fix: guard copyExportedFields against nil interface values in slices, maps, and pointers#127

Merged
fredbi merged 1 commit into
masterfrom
copilot/fix-failing-unit-tests
Jun 19, 2026
Merged

fix: guard copyExportedFields against nil interface values in slices, maps, and pointers#127
fredbi merged 1 commit into
masterfrom
copilot/fix-failing-unit-tests

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown

copyExportedFields panics when encountering nil interface elements inside slices, maps, or pointer targets. reflect.ValueOf(nil) returns a zero reflect.Value; calling .Set() with it panics. Discovered by the rapid-based fuzz test TestNilSafetyExportedValues.

panic after 72 tests: reflect: call of reflect.Value.Set on zero Value

draw a: []interface {}{interface {}(nil), 0, "hello", interface {}(nil)}
draw b: []interface {}(nil)

Changes

  • internal/assertions/equal.go — Add nil guards after each recursive copyExportedFields call in the slice/array, map, and pointer branches. Nil results skip Set, preserving the zero value (correct semantics: nil interface has no exported fields).
  • Remove stale rapid fail file for TestNilSafetyExportedValues.
  • Regenerated docs via go generate ./... (line number shifts from recent changes).

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@57d0e4e). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #127   +/-   ##
=========================================
  Coverage          ?   91.66%           
=========================================
  Files             ?       97           
  Lines             ?    12623           
  Branches          ?        0           
=========================================
  Hits              ?    11571           
  Misses            ?      828           
  Partials          ?      224           

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

…s in slices, maps, and pointers

When copyExportedFields recursively processes elements in slices, maps,
or pointer targets that are nil interfaces, it returns nil.

Calling reflect.ValueOf(nil) produces a zero reflect.Value, which panics when
passed to Set. Add nil guards after each recursive call.

Also removes a stale rapid fail file and regenerates docs.

Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
Co-Authored-by: copilot-swe-agent[bot] <198982749+copilot-swe-agent[bot]@users.noreply.github.com>
@fredbi fredbi force-pushed the copilot/fix-failing-unit-tests branch from bfffa87 to bbe0caf Compare June 19, 2026 13:08
@fredbi fredbi marked this pull request as ready for review June 19, 2026 13:16
@fredbi fredbi merged commit df56554 into master Jun 19, 2026
35 of 37 checks passed
@fredbi fredbi deleted the copilot/fix-failing-unit-tests branch June 19, 2026 13:35
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.

2 participants