Skip to content

Fix delByKeyPath so that it does not create empty object when keyPath is dotted (deep). - #2303

Merged
dfahlander merged 2 commits into
masterfrom
fix-delByKeyPath
May 27, 2026
Merged

Fix delByKeyPath so that it does not create empty object when keyPath is dotted (deep).#2303
dfahlander merged 2 commits into
masterfrom
fix-delByKeyPath

Conversation

@dfahlander

@dfahlander dfahlander commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Deletion now avoids creating unnecessary intermediate empty objects when removing nested entries.
  • Tests

    • Added regression tests to ensure deletions along missing paths do not produce empty intermediates and do not affect siblings.
  • Chores

    • Package version bumped to 4.4.3.

Review Change Stack

… is dotted (deep).

Co-authored-by: Copilot <copilot@github.com>
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3e84dcd-75d0-4bf6-bf74-4630ded62b59

📥 Commits

Reviewing files that changed from the base of the PR and between 27a1467 and f0053d2.

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

This PR fixes setByKeyPath in the utils module to prevent unintended side effects when deleting keys along missing paths. The implementation now skips intermediate object creation for delete operations on non-existent keys, while preserving the existing behavior for write operations. A new regression test validates the fix across multiple scenarios.

Changes

Deletion behavior fix and test

Layer / File(s) Summary
setByKeyPath deletion logic and regression test
src/functions/utils.ts, test/tests-misc.js
setByKeyPath returns early when deleting (value === undefined) a non-existent nested key, avoiding intermediate empty object creation. Regression test asserts the behavior for six scenarios: empty objects, deeper missing paths, sibling preservation, existing leaves, intermediate object retention, and both string and array keyPath forms.
Package version bump
package.json
Increment package version from 4.4.2 to 4.4.3.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A path through the void, no more marks in the sand,
When deletion flows down where no keys yet stand,
We skip the false objects that cluttered before,
Now delByKeyPath leaves the structure more pure! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing delByKeyPath to avoid creating empty intermediate objects when using dotted (deep) keypaths, which matches the core change in the utils.ts file and regression test.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-delByKeyPath

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dfahlander
dfahlander merged commit 0919742 into master May 27, 2026
4 of 7 checks passed
@dfahlander
dfahlander deleted the fix-delByKeyPath branch May 27, 2026 13:59
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