Repository navigation
fix(core): log errors inside event fields instead of {} - #778
Conversation
|
@adelrodriguez is attempting to deploy a commit to the HRCD Projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (3)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughLogger event fields and request-logger context fields now sanitize ChangesError field serialization
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Nested errors now retain useful details in event and request-logger output instead of becoming empty objects, while ordinary acyclic fields remain unchanged. No concrete merge-blocking risk remains. Architecture SummaryArchitecture risk: 🟠 High · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for following the naming conventions! 🙏 |
🔗 Linked issue
Resolves #776
📚 Description
An
Errorinside a wide event was logged as{}.log.error({ error, message: 'Job failed' })kept the message and lost the error that explained the failure, at any key and any depth.set({ error })on a request logger lost it the same way.JSON.stringifyreceived the rawError, and itsname,message, andstackare not enumerable.Only
log.error(err)went throughserializeError. Now the object form oflog.*and every request-logger entry point that merges caller fields (set()and the context argument oferror,fatal,info,warn,trace) pass the fields throughremoveErrorCyclesfirst. That function already serializes anErrorat any depth and returns the input unchanged when it holds none.log.error({ ... }) - emitWideEvent(level, event) + emitWideEvent(level, removeErrorCycles(event)) logger.set(fields) / logger.warn(msg, fields) / ... - mergeInto(context, fields) + mergeFields(context, fields) // mergeInto(context, removeErrorCycles(fields))The level-method contexts are a step past the two call sites confirmed in the issue. They had the same bug:
logger.warn('Retrying', { failure: err })also wrote{}.The reproduction from the issue, before:
After, against a fresh build:
Two regression tests cover both paths. They failed before the fix and pass now.
pnpm run lint,pnpm run typecheck,pnpm run test(2010 evlog tests), andpnpm test:coveragepass. A patch changeset is included.Merge risk: two-way door. The blast radius is the core logger. A caller that read a raw
Errorback fromgetContext()afterset()now gets the serialized object, the same shapelogger.error(err)already stores.📝 Checklist
Summary by CodeRabbit