Skip to content

Conversation

@fredbi
Copy link
Member

@fredbi fredbi commented Jan 10, 2026

  • fixed case of circular reference that hangs
  • fixed unrecoverable panic when dumping a map with a circular reference

test(integrationtest): added new module for integration tests

This new module takes a systematic approach to explore edge cases in spew by producing random scenarios with uncommon data types.

This approach uncovered 2 bugs in spew (fixed above)... and one in the fmt standard library.

This new module leverages the rapid library to build generators and exercises spew.Sdump. The "property based" tests produced with rapid are generalized in a fuzz test.

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
Copy link
Member Author

fredbi commented Jan 10, 2026

@ccoVeille you might find this one interesting. This PR takes a systematic approach to exploring edge cases in spew.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes two critical bugs in the internalized spew package that caused hangs and panics, and adds a comprehensive property-based testing framework to catch such issues in the future.

Changes:

  • Fixed circular reference hang when an interface contains a self-referencing pointer
  • Fixed panic/hang when dumping maps with circular references
  • Added new integration test module using rapid for property-based testing

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/spew/dump.go Fixed circular reference detection in pointers wrapped in interfaces; extracted map dumping to dedicated function with cycle detection
internal/spew/edgecases_test.go Added edge case tests for the fixed scenarios (circular maps, pointer-to-interface patterns)
internal/assertions/doc.go Added documentation link for API search by domain
go.work Added testintegration module to workspace
.golangci.yml Increased gocognit complexity threshold to 35
internal/testintegration/go.mod New module for integration tests with rapid dependency
internal/testintegration/go.sum Dependency checksums
internal/testintegration/README.md Comprehensive documentation of test architecture and usage
internal/testintegration/spew/doc.go Package documentation
internal/testintegration/spew/options.go Options system for test generators
internal/testintegration/spew/generator.go Reflection-based random value generator for comprehensive testing
internal/testintegration/spew/generator_test.go Tests for the generator itself
internal/testintegration/spew/edgecases.go Hand-crafted edge case generators for known problematic patterns
internal/testintegration/spew/edgecases_test.go Tests using edge case generators
internal/testintegration/spew/dump_test.go Main property-based tests with rapid.Check
internal/testintegration/spew/dump_fuzz_test.go Go native fuzz tests integrated with rapid

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 93.30025% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.68%. Comparing base (a77bd23) to head (748f31b).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/testintegration/spew/generator.go 88.04% 27 Missing and 14 partials ⚠️
internal/testintegration/spew/edgecases.go 97.02% 7 Missing and 5 partials ⚠️
internal/spew/dump.go 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
+ Coverage   88.21%   88.68%   +0.46%     
==========================================
  Files          60       63       +3     
  Lines        7467     8244     +777     
==========================================
+ Hits         6587     7311     +724     
- Misses        735      769      +34     
- Partials      145      164      +19     

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

* fixed case of circular reference that hangs
* fixed unrecoverable panic when dumping a map with a circular reference

test(integrationtest): added new module for integration tests

This new module takes a systematic approach to explore edge cases in
spew by producing random scenarios with uncommon data types.

This approach uncovered 2 bugs in spew (fixed above)... and one in the
fmt standard library.

This new module leverages the rapid library to build generators and exercises spew.Sdump.
The "property based" tests produced with rapid are generalized in a fuzz test.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi force-pushed the test/explore-panic branch from 9a8080e to 748f31b Compare January 10, 2026 21:20
@fredbi fredbi merged commit c217cc4 into go-openapi:master Jan 11, 2026
20 of 21 checks passed
@fredbi fredbi deleted the test/explore-panic branch January 11, 2026 09:57
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