Repository navigation
fix(shared): fix deepMerge data-corruption bugs and add tests - #4136
kridaydave wants to merge 2 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
250dfdc to
966cd6b
Compare
ApprovabilityVerdict: Needs human review This bug fix introduces meaningful runtime behavior changes to a shared You can customize Macroscope's approvability policy. Learn more. |
|
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened. Closing because this change does not address a demonstrated settings failure. Current callers merge schema-validated settings objects, not class instances or primitive patches. The new shared throw changes behavior for inputs outside that settings path. A failing case through a supported settings path would justify a focused fix. |
Fixes two deepMerge bugs: it destroyed Date/Map/class-instance values (prototype loss) and silently discarded the entire base on a primitive patch.
All gates green (typecheck, check, test).
Note
Medium Risk
Shared utility behavior change: callers that passed a non-null primitive or array as the top-level patch will now throw instead of getting a silent wrong result; merge semantics for non-plain nested values also change.
Overview
deepMergeinStruct.tsnow recurses only when both sides are plain objects (Object.prototype), soDate,Map, class instances, arrays, and functions are replaced wholesale instead of being walked like nested records (which brokeDateprototypes and similar values).Invalid top-level patches throw instead of silently returning a primitive and dropping the base object;
nullat the top level is still allowed.New
Struct.test.tsandStruct.edgeCases.test.tslock in normal merge behavior and document remaining quirks (array overwrite,nullnot skipped, shallow copy of nested refs).Reviewed by Cursor Bugbot for commit 3405a01. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix data-corruption bugs in
deepMergeand add test coverageisPlainObjectin Struct.ts to restrict recursion to plain objects; dates, maps, and class instances are now overwritten rather than recursively merged.deepMergenow throws when the top-level patch is a non-null primitive (e.g. number, array, function) instead of silently returning it.Macroscope summarized 3405a01.