cleanDataKeys() in schema.ts deletes the entire seo object when seo.title/seo.description match the top-level fields - silently discarding seo.keywords and any other nested properties.
Reproduction
---
title: My Post
description: A summary.
seo:
title: My Post
description: A summary.
keywords:
- example
- seo
---
After Studio saves → seo is completely gone, keywords lost.
Root cause
// schema.ts – cleanDataKeys()
if (
(!seo.title || seo.title === document.title)
&& (!seo.description || seo.description === document.description)
) {
Reflect.deleteProperty(result, 'seo') // deletes keywords too
}
Question: should cleanDataKeys modify user data at all?
The "optimization" of removing redundant seo.title/seo.description is arguably not the serializer's job. The user explicitly put those values there — keeping them is safe, removing them risks data loss (as demonstrated). A content formatter should preserve what the user wrote, not silently decide what's redundant.
If stripping is desired, the minimal safe fix would be to only strip individual redundant fields, never the whole object:
const seo = { ...(document.seo as Record<string, unknown>) }
if (!seo.title || seo.title === document.title) delete seo.title
if (!seo.description || seo.description === document.description) delete seo.description
if (Object.keys(seo).length === 0) {
Reflect.deleteProperty(result, 'seo')
} else {
result.seo = seo
}
But the safest approach would be to not strip anything from seo and let the data stay as-is.
cleanDataKeys()inschema.tsdeletes the entireseoobject whenseo.title/seo.descriptionmatch the top-level fields - silently discardingseo.keywordsand any other nested properties.Reproduction
After Studio saves →
seois completely gone,keywordslost.Root cause
Question: should
cleanDataKeysmodify user data at all?The "optimization" of removing redundant
seo.title/seo.descriptionis arguably not the serializer's job. The user explicitly put those values there — keeping them is safe, removing them risks data loss (as demonstrated). A content formatter should preserve what the user wrote, not silently decide what's redundant.If stripping is desired, the minimal safe fix would be to only strip individual redundant fields, never the whole object:
But the safest approach would be to not strip anything from
seoand let the data stay as-is.