Skip to content

fix(schema-org): allow null to opt out of default values - #688

Merged
harlan-zw merged 2 commits into
fix/548-empty-schema-org-valuesfrom
copilot/sub-pr-680-again
Mar 10, 2026
Merged

harlan-zw merged 2 commits into
fix/548-empty-schema-org-valuesfrom
copilot/sub-pr-680-again

Conversation

Copilot AI commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #548

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

setIfEmpty had no opt-out mechanism — fields like sku, priceValidUntil, and url would always receive injected defaults. Setting a property to null now acts as an explicit sentinel to suppress default injection.

Changes:

  • setIfEmpty — guard changed from falsy to === undefined so null blocks injection while 0, false, and '' are now valid defaults
  • stripNullProperties — added array-aware path: splices out null entries instead of delete (which creates sparse arrays that JSON.stringify re-serializes as null)
  • graph.ts cleanup loop — deferred stripNullProperties + delete _resolver to a second pass after all resolveRootNode calls complete, so later resolvers see sentinels on earlier nodes; _resolver is now deleted before stripping to prevent traversal into resolver objects
// Before: no way to suppress auto-injected url
defineProduct({ name: 'Widget' }) // url always injected from page

// After: null explicitly opts out
defineProduct({ name: 'Widget', url: null }) // url omitted from output

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix schema-org to allow null to opt out of default values fix(schema-org): allow null to opt out of default values Mar 10, 2026
@harlan-zw
harlan-zw marked this pull request as ready for review March 10, 2026 13:34
@harlan-zw
harlan-zw merged commit 0b9a46d into fix/548-empty-schema-org-values Mar 10, 2026
harlan-zw added a commit that referenced this pull request Mar 10, 2026
* fix(schema-org): allow null to opt out of default values

When a user sets a schema-org property to null, it is now removed from
the final output instead of being overwritten by setIfEmpty defaults or
inheritMeta. null acts as an explicit opt-out sentinel that is preserved
through the full resolution pipeline and stripped only after all
resolvers (including resolveRootNode) have run.

Closes #548

* fix(schema-org): allow null to opt out of default values (#687)

* Initial plan

* fix(schema-org): address CodeRabbit issues with null opt-out implementation

Co-authored-by: harlan-zw <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: harlan-zw <[email protected]>

* fix(schema-org): allow null to opt out of default values (#688)

* Initial plan

* fix(schema-org): delete _resolver before stripping null properties

Co-authored-by: harlan-zw <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: harlan-zw <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: harlan-zw <[email protected]>
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.

2 participants