Skip to content

fix(rules): align json-ld-valid with schema.org and Google #469 - #500

Merged
nc9 merged 1 commit into
mainfrom
fix/rules-469
Oct 6, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/rules-469

Conversation

@nc9

@nc9 nc9 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Closes #469

Cause

packages/parser/src/schema/validator.ts, behind schema/json-ld-valid, read schema.org more strictly than schema.org or Google do:

  • recipeIngredient and recipeInstructions were typed array, so a single string reported must be an array.
  • Product.offers required price/priceCurrency/availability on every offer, including an AggregateOffer, which carries lowPrice instead.
  • Article.publisher and publisher.logo were required.
  • extractSchemas kept only typed nodes, so a reference to an untyped top-level @graph node was checked as written.
  • The item rules on BreadcrumbList.itemListElement and FAQPage.mainEntity never ran: validatePropertyType returned before its array/item branch because rule.required was unset at that level. A single object was also rejected there with must be an array.

Fix

  • recipeIngredient takes a string or list of strings. recipeInstructions takes text, an object (HowToStep, HowToSection), or a list of either.
  • FAQPage.mainEntity and BreadcrumbList.itemListElement take one entry or a list, and their entry checks now run:
    • Each question needs name and acceptedAnswer.
    • Each crumb needs position, name and item, except the last crumb, which may omit item (Google's exemption). The last crumb is the highest position, falling back to written order when no crumb has one.
    • A crumb given by {"@id"} takes its fields, including position, from the node it names. A name on the crumb's item node counts, inline or by reference.
  • A new requiredByType gives AggregateOffer its own list, lowPrice and priceCurrency, which Google requires for it.
  • Article.publisher is no longer required, and a given publisher needs only name.
  • The parser now keeps top-level nodes that have an @id and no @type beside the schemas (SchemaCollection.untypedNodes, stored and rehydrated). validateSchemas(schemas, untypedNodes) indexes them for reference resolution. They are not validated as schemas. Bare {"@id"} nodes are not kept.
  • docs/rules/schema/json-ld-valid.mdx describes each of these.

Running the breadcrumb and FAQ checks adds findings that never showed before: a crumb before the last with no item, a question with no answer. That is the "fixing it adds findings" side the issue calls out. The real run below shows one.

Proof

Real run, CLI from source against a local fixture (python3 -m http.server): five pages, audit --http --offline --refresh -m 6 --rule-include schema/json-ld-valid -f json.

  • recipe: single-string ingredient and instructions
  • product: AggregateOffer
  • article: Person publisher with no logo, author referencing an untyped @graph node
  • faq: a single Question
  • crumbs: 3 crumbs, the 2nd and the last with no item
=== BEFORE (origin/main)
json-ld-valid fail on: article, faq, product, recipe
items: Article:author.name, Article:publisher.logo, FAQPage:mainEntity, Product:offers.availability,
       Product:offers.price, Recipe:recipeIngredient, Recipe:recipeInstructions
=== AFTER (this branch)
json-ld-valid fail on: crumbs
items: BreadcrumbList:itemListElement.item    (the 2nd crumb; the last crumb is exempt)

Tests

packages/rules/tests/json-ld-valid.test.ts: 55 tests, 20 of them new. 17 fail against the origin/main validator. They cover each acceptance criterion plus the kept true positives:

  • Offer without price; AggregateOffer without lowPrice
  • publisher without name
  • question without an answer; crumb before the last without item; unnamed crumb
  • written-last vs highest position; crumbs by reference
  • malformed position and a @type of constructor do not throw

Three existing assertions on publisher.logo were updated.

Also run and passing: schema-graph-flattening, schema-entity-rules, schema-coverage-outlier, core-canonical-form-drift (184); streaming-rules-canonical, site-query-schema-coverage, entity-rules goldens (28); rule-cache codec / replay / page-rule-site-context (31); template-verdict-page-independence (78); CLI graph schema extractor and prototype-pollution (27). tsgo --noEmit clean in packages/parser and packages/rules. [email protected] check --strict passes.

Notes

  • A page reused from the crawl cache that an older release parsed has no stored untyped nodes, so a reference to one resolves after the page is fetched again or with --refresh. Everything else is re-validated at audit time as before. This is documented on the rule page.
  • Left as is, outside this issue: Article still requires headline/image/datePublished/author, Recipe its ingredients and instructions, and an Offer its availability. Google lists these as recommended. Also left: an AggregateOffer whose type appears only on a bare typed reference elsewhere in the graph is treated as an Offer.

Changelog suggestion

  • Fixed: schema/json-ld-valid no longer flags valid markup: a single recipe ingredient or instruction, a single FAQ question or breadcrumb, an AggregateOffer, an Article without a publisher logo, or a reference to an untyped @graph node. It now checks every breadcrumb and FAQ question, with the last breadcrumb exempt from item.

@nc9
nc9 marked this pull request as ready for review October 6, 2026 13:55
The validator behind schema/json-ld-valid flagged valid markup:
- a single recipeIngredient/recipeInstructions, FAQPage.mainEntity or
  BreadcrumbList.itemListElement, where any JSON-LD property may hold one
  value or a list
- an AggregateOffer for lacking price and availability; it now needs
  lowPrice and priceCurrency
- an Article without a publisher, or a Person publisher without a logo
- a reference to an untyped top-level @graph node, which the parser
  dropped; such nodes are now kept beside the schemas and indexed

The BreadcrumbList and FAQPage entry checks never ran. They now do, with
Google's exemption: the last crumb by position needs no item, and a name
on the crumb's item node counts.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 merged commit 60dd682 into main Oct 6, 2026
14 checks passed
@nc9
nc9 deleted the fix/rules-469 branch October 6, 2026 14:04
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.

schema/json-ld-valid: validator still stricter than schema.org/Google (arrays, AggregateOffer, publisher)

1 participant