Skip to content

Fix didPanic to use type assertion for runtime.PanicNilError instead of string comparison#124

Merged
fredbi merged 2 commits into
masterfrom
copilot/fix-didpanic-error-string-equality
Jun 18, 2026
Merged

Fix didPanic to use type assertion for runtime.PanicNilError instead of string comparison#124
fredbi merged 2 commits into
masterfrom
copilot/fix-didpanic-error-string-equality

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown

didPanic detects panic(nil) by comparing err.Error() == "panic called with nil argument". Go 1.27 changes this error string (golang/go#63813, CL 791540), breaking the check.

  • Replace string equality check with a direct *runtime.PanicNilError type assertion, which is the stable API available since Go 1.21
// Before
if err, ok := message.(error); ok {
    if err.Error() == "panic called with nil argument" {
        message = nil
    }
}

// After
if _, ok := message.(*runtime.PanicNilError); ok {
    message = nil
}

… comparison

The didPanic function previously checked for runtime.PanicNilError by
comparing the Error() string "panic called with nil argument". This
breaks in Go 1.27 where the error message changes.

Use a direct type assertion for *runtime.PanicNilError instead, which
is the stable API and works across all Go versions from 1.21 onward.

Closes #123

Signed-off-by: GitHub Copilot <copilot@github.com>
Copilot AI changed the title [WIP] Fix didPanic to handle Go 1.27 panic error string changes Fix didPanic to use type assertion for runtime.PanicNilError instead of string comparison Jun 18, 2026
Copilot AI requested a review from fredbi June 18, 2026 16:55
@fredbi fredbi marked this pull request as ready for review June 18, 2026 16:57
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.69%. Comparing base (a0b676d) to head (15fd903).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
+ Coverage   91.68%   91.69%   +0.01%     
==========================================
  Files          97       97              
  Lines       12602    12601       -1     
==========================================
+ Hits        11554    11555       +1     
+ Misses        826      825       -1     
+ Partials      222      221       -1     

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

@fredbi fredbi merged commit 8244b25 into master Jun 18, 2026
31 of 33 checks passed
@fredbi fredbi deleted the copilot/fix-didpanic-error-string-equality branch June 18, 2026 17:12
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