Skip to content

Fix: replace pkg/errors.Cause() with a bounded rootCause - #305

Open
mrizk wants to merge 4 commits into
foomo:mainfrom
mrizk:fix/Telemetry-errors.Cause()-infinite-loop
Open

Fix: replace pkg/errors.Cause() with a bounded rootCause#305
mrizk wants to merge 4 commits into
foomo:mainfrom
mrizk:fix/Telemetry-errors.Cause()-infinite-loop

Conversation

@mrizk

@mrizk mrizk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

If the telemetry helper funcs EndSpan/DeferEndSpan/RecordError are given an error that implements Cause() err and returns itself, then pkg/errors.Cause goes into an infinite loop. This PR replaces errors.Cause() with a bounded rootCause() helper.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactoring
  • 🏃‍➡️ Performance
  • ✅ Tests
  • 🔐 Security
  • 🔧 Build/CI

Related Issues

None

Changes

  • replace pkg/errors.Cause() with a bounded rootCause() helper
  • add unit tests to verify fix

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

Notes

Not sure if 100 is excessive. Could in theory be much smaller but I didn't want the change to possibly break anything else.

@mrizk

mrizk commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

FYI @franklinkim
also here's the related gotsrpc fix: foomo/gotsrpc#112

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