Skip to content

Fix: Error.Cause() returning itself - #112

Open
mrizk wants to merge 2 commits into
foomo:mainfrom
mrizk:fix/Error-Cause-returning-itself
Open

Fix: Error.Cause() returning itself#112
mrizk wants to merge 2 commits into
foomo:mainfrom
mrizk:fix/Error-Cause-returning-itself

Conversation

@mrizk

@mrizk mrizk commented Aug 19, 2026

Copy link
Copy Markdown

Description

Error.Cause() currently returns itself if there's no ErrCause set, which when passed into pkg/errors.Cause() leads to an infinite busy loop.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactoring
  • ⚡ Performance
  • ✅ Tests
  • 🔧 Build/CI

Related Issue

None

Changes

  • Return nil if an Error has no ErrCause
  • 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

Could be a breaking change if some caller somewhere relies on Cause() never returning nil.

@mrizk

mrizk commented Aug 20, 2026

Copy link
Copy Markdown
Author

FYI @franklinkim
also here's the related keel fix: foomo/keel#305

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