fix: coerce non-string da-metadata values to avoid "[object Object]"#933
Draft
chrischrischris wants to merge 1 commit into
Draft
fix: coerce non-string da-metadata values to avoid "[object Object]"#933chrischrischris wants to merge 1 commit into
chrischrischris wants to merge 1 commit into
Conversation
setDaMetadata is the single boundary into the daMetadata Y.Map, but it
forwarded values verbatim. doc2aem later interpolates each value into a
<div>${value}</div>, so any non-string entry (object, Y type) ended up
serialized as the literal string "[object Object]" in saved HTML.
Coerce at the boundary: stringify objects via JSON.stringify, other
non-strings via String(), and warn so the offending caller surfaces.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
Commits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setDaMetadatais the single boundary into thedaMetadataY.Map, but it forwarded values verbatim.doc2aemlater interpolates each value into<div>${value}</div>, so any non-string entry (object, Y type) ends up serialized as the literal string[object Object]in saved HTML — observed in the wild as:JSON.stringify, other non-strings viaString(), andconsole.warnso the offending caller is visible in dev tools next time it happens.Notes for reviewers
addToHashMetadataand the version-restore loop inda-editor.js) already passes strings, and the lowercase keys (acceptedhashes/rejectedhashes) in the observed HTML don't match ourACCEPTED_KEY/REJECTED_KEYconstants (acceptedHashes/rejectedHashes) — so the corrupt entries likely came from outsidesetDaMetadataentirely. The newconsole.warnshould help surface the source.da-parser'sdoc2aem(parser.js:753), which neither stringifies nor HTML-escapes the keys/values. Happy to put up a PR there as a follow-up.Test plan
npx web-test-runner test/unit/blocks/edit/utils/helpers.test.js— 64 passing, including new coercion tests.[object Object]inda-metadata), open it in da-live, edit, save, and confirm no new[object Object]rows are written.🤖 Generated with Claude Code