fix(key-value): display null values as 'null' string after CSV import#35401
Conversation
- Old Edit Content (JSP): remove null guard that silently dropped key-value pairs with null values; null is now rendered as the string "null" - New Edit Content (Angular): convert JSON null to the string "null" in parseToDotKeyValue so imported null values are visible in the UI - Stencil dot-key-value: add safety-net regex for ":null format in case the component receives raw HTML-encoded JSON with unquoted null Fixes #32823 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @adrianjm-dotCMS's task in 3m 7s —— View job Code Review
The fix is correct for the stated goal. Two things worth calling out, one of which is a design decision that should be explicitly acknowledged: Round-trip semantic change (intentional but undocumented)When a user saves a contentlet that was imported with
This means: import with If preserving the distinction matters, the save path would need a reverse conversion ( Stencil regex is a safety net that the JSP path never triggersThe new regex in handles unquoted This is fine as a safety net, but the silent ordering dependency is fragile: this line must precede the Minor
Overall: clean fix. The round-trip concern is the only substantive question — worth a conscious decision either way. |
There was a problem hiding this comment.
Pull request overview
Fixes a regression where key/value entries with null values imported via CSV were not displayed in either the legacy JSP edit screen or the new Angular edit experience, by consistently surfacing null as the literal string "null" and adding a defensive parsing step in the dot-key-value web component.
Changes:
- Legacy Edit Content (JSP): include
null-valued entries during key/value serialization instead of skipping them. - New Edit Content (Angular): map imported
nullvalues to the string"null"inparseToDotKeyValue. - Web component + tests: add a parsing “safety net” for HTML-encoded JSON with unquoted
null, plus new unit/e2e test coverage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp | Stops dropping null values when building key/value payloads for the legacy UI. |
| core-web/libs/ui/src/lib/components/dot-key-value-ng/dot-key-value-table-row/dot-key-value-table-row.component.spec.ts | Adds a unit test ensuring "null" renders in the value input. |
| core-web/libs/edit-content/src/lib/fields/dot-edit-content-key-value/dot-edit-content-key-value.component.spec.ts | Updates the import-related expectation from '' to 'null'. |
| core-web/libs/edit-content/src/lib/fields/dot-edit-content-key-value/components/key-value-field/key-value-field.component.ts | Changes null-coalescing logic to preserve null as 'null' instead of empty string. |
| core-web/libs/dotcms-webcomponents/src/components/contenttypes-fields/dot-key-value/dot-key-value.tsx | Adds parsing normalization for HTML-encoded JSON where values may be unquoted null. |
| core-web/libs/dotcms-webcomponents/src/components/contenttypes-fields/dot-key-value/dot-key-value.e2e.ts | Adds e2e coverage for unquoted null values in HTML-encoded JSON. |
Problem
When importing content via CSV with key/value fields containing
nullvalues (e.g.{"my-value": null}), the keys were silently dropped from both the Old and New Edit Content UIs.Fixes #32823
Root Causes & Fixes
Old Edit Content (JSP —
edit_field.jsp)The Java code had
if(null != object)which skipped null-valued entries entirely before they reached the Stencil web component. Now null values are included as the string"null".New Edit Content (Angular —
key-value-field.component.ts)parseToDotKeyValueuseddata[key] ?? ''which converted null to empty string, making it indistinguishable from an intentionally empty value. Now null maps to the string"null".Stencil
dot-key-value(safety net —dot-key-value.tsx)Added a regex to handle the
":nullpattern in case the component receives raw HTML-encoded JSON with an unquoted null value from any other source.Behavior After Fix
{"key": null}key → nullkey → null{"key": ""}key → (empty)key → (empty){"key": "value"}key → valuekey → valueTest plan
{"my-value": null}and open in Old Edit Content — key and valuenullshould be visible{"my-value": null}and open in New Edit Content — key and valuenullshould be visible{"key": ""}still shows as empty (notnull)yarn nx test edit-contentandyarn nx test ui🤖 Generated with Claude Code
This PR fixes: #32823