Skip to content

fix: treat null and arrays as non-mergeable in mergeJson - #13147

Open
tonycoder-hub wants to merge 1 commit into
continuedev:mainfrom
tonycoder-hub:cursor/fix-mergejson-null-and-array-type-mismatch-573d
Open

fix: treat null and arrays as non-mergeable in mergeJson#13147
tonycoder-hub wants to merge 1 commit into
continuedev:mainfrom
tonycoder-hub:cursor/fix-mergejson-null-and-array-type-mismatch-573d

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Description

mergeJson used typeof value === "object" so null and arrays were treated as mergeable objects.

That produced three incorrect results:

  • mergeJson({a: {b: 1}}, {a: null}) kept the object instead of clearing it
  • mergeJson({a: null}, {a: {b: 1}}) threw internally
  • mergeJson({a: {b: 1}}, {a: [1, 2]}) produced a hybrid object

isMergeableObject now gates recursion. On a type mismatch, the second value wins.

Distinct from #13143, #13144, #13145, and #13146.

Checklist

  • I have read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Tests

core/util/merge.test.ts: 14 passed

typeof null === "object", so a null in the second config was recursed
into instead of replacing the first object, silently dropping explicit
nulls. Arrays hit the same branch when only one side was an array,
either ignoring the second value or producing an array/object hybrid.

Co-authored-by: Tony Coder <407243179@qq.com>
@tonycoder-hub
tonycoder-hub requested a review from a team as a code owner August 17, 2026 10:35
@tonycoder-hub
tonycoder-hub requested review from sestinj and removed request for a team August 17, 2026 10:35
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@tonycoder-hub

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@tonycoder-hub

Copy link
Copy Markdown
Author

recheck

@cursor
cursor Bot force-pushed the cursor/fix-mergejson-null-and-array-type-mismatch-573d branch from 37f2e71 to 3b9ce7d Compare August 17, 2026 10:44
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