fix(utils): handle null safely and check instanceof before buffer property in isJSONSerializable - #636
fix(utils): handle null safely and check instanceof before buffer property in isJSONSerializable#636swaraj792725 wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesJSON serializability checks
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The serializability changes appear ready to merge after normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
Summary
Fixes #571 and #580.
Previously, had two critical bugs:
"object", not"null". The checkif (t === "null")was dead code, causingisJSONSerializable(null)to fall through tovalue.buffer, throwingTypeError: Cannot read properties of null (reading 'buffer').value.bufferproperty check was performed beforeinstanceof FormDataandinstanceof URLSearchParams, and without checking whetherFormData/URLSearchParamsare defined in the global context.Fix
value === nullexplicitly up front (returningtruesincenullis a valid JSON value).instanceofchecks forFormDataandURLSearchParamsbefore checkingvalue.buffer, and guard withtypeof FormData !== "undefined".Object.create(null)without crashing on missingconstructor.Test Plan
isJSONSerializablecoveringnull,undefined, primitives, objects created withObject.create(null),FormData, andURLSearchParams.Summary by CodeRabbit