Skip to content

fix: refactor update data to avoid lodash issues - #2585

Merged
lucas-koehler merged 7 commits into
masterfrom
fix-2397
Jul 31, 2026
Merged

fix: refactor update data to avoid lodash issues#2585
lucas-koehler merged 7 commits into
masterfrom
fix-2397

Conversation

@sdirix

@sdirix sdirix commented May 28, 2026

Copy link
Copy Markdown
Member

Replace the lodash/fp/set call in UPDATE_DATA with a dedicated helper. This fixes issues with numeric segments (e.g. "group-key.15") and bracket characters in property names (e.g. "test[0]").

Fixes #2102
Fixes #2397

@sdirix
sdirix requested a review from lucas-koehler May 28, 2026 15:09
@netlify

netlify Bot commented May 28, 2026

Copy link
Copy Markdown

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 1616bf2
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/6a6c68ab49cf120008c96a6a
😎 Deploy Preview https://deploy-preview-2585--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coveralls

coveralls commented May 28, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 84.286% (+0.5%) from 83.776% — fix-2397 into master

Replace the lodash/fp/set call in UPDATE_DATA with a dedicated helper.
This fixes issues with numeric segments (e.g. "group-key.15") and
bracket characters in property names (e.g. "test[0]").

Fixes #2102
Fixes #2397

@lucas-koehler lucas-koehler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me already 🚀
I have one minor concern inline. please have a look :)

Comment thread packages/core/src/util/setData.ts Outdated
Comment thread packages/core/src/util/setData.ts Outdated
sdirix added 2 commits June 3, 2026 11:10
Improvements on top of the lodash/fp/set replacement:

- Store "__proto__" segments as own properties via defineProperty and
  traverse own properties only, so such keys neither corrupt the
  container's prototype nor get dropped. Clone containers key-by-key
  because downleveled object spreads assign instead of define.
- Read the updater's old data with resolveData instead of lodash get,
  so reads use the same literal path semantics as writes.
- Fall back to lodash's index heuristic when creating missing
  containers without schema type information.
- Match lodash's isIndex semantics with a strict index regex instead
  of Number() coercion.
- Avoid strict-mode TypeErrors when unsetting non-index array
  properties (e.g. "length") and return the same reference when
  there is nothing to unset.
- Treat an empty path as addressing the root, and replace non-object
  root data instead of spreading it.

Also documents the path semantics change in MIGRATION.md and adds unit
tests for setDataAt/unsetDataAt.

@lucas-koehler lucas-koehler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update and advanced edge case handling 🚀
The changes already looks pretty good to me. I only have one question and one needed updated for the migration guide. Please have a look :)

Comment thread packages/core/src/util/setData.ts Outdated
Comment thread MIGRATION.md Outdated
Added heading "Migration to JSON Forms 3.9" and moved "Data update paths
treat all segments literally" from "Mifration to JSON Forms 3.8" to
"Migration to JSON FOrms 3.9". This resolves the change request comment
for `MIGRATION.md` file in PR #2585.
Added strict equality checks (`!== null && !== undefined`) inside
`ownPropertyValue`. This resolves comment in PR #2585 regarding use of loose inequality.
@lucas-koehler
lucas-koehler merged commit dc02a1c into master Jul 31, 2026
11 checks passed
@lucas-koehler
lucas-koehler deleted the fix-2397 branch July 31, 2026 09:36
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.

Update data bug on nested property with numeric key Cannot enter values in field with brackets in property name

4 participants