Skip to content

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

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

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

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 escape hatch — properties like sku, priceValidUntil, and url were always auto-populated with no way to suppress them. Setting a property to null now acts as an explicit opt-out sentinel, preventing default injection.

Changes:

  • setIfEmpty: Guard changed from truthy value → value != null, so falsy-but-valid defaults (0, false, '') are also injected correctly
  • stripNullProperties (array handling): Arrays now use splice instead of delete on numeric indices — delete creates sparse arrays where holes serialize back to null in JSON.stringify, defeating the opt-out
  • graph.ts second pass: Split the resolve loop into two phases — all resolveRootNode handlers run first, then null stripping and _resolver cleanup happen in a separate pass. Previously, earlier nodes had their sentinels erased before later resolvers could observe them, making behavior iteration-order dependent
defineProduct({
  name: 'My Product',
  sku: null,           // suppresses auto-generated SKU
  description: null,   // suppresses meta description inheritance
  offers: [{
    price: 50,
    priceValidUntil: null,   // suppresses default expiry date
    priceCurrency: null,     // suppresses default currency
  }],
})

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

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:05
@harlan-zw
harlan-zw merged commit e577133 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