Repository navigation
fix(rules): json-ld-valid accepts an ImageObject for image and logo #463 - #468
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 6, 2026 00:49
image and logo have the schema.org range ImageObject | URL; the validator only took strings. Bare {"@id"} references now resolve against every description of that id on the page, so an @unhead/schema-org (Nuxt) graph validates clean. The rule re-validates at audit time instead of replaying the issues stored with a crawl-cache-reused page, reports validation messages once (not again as parse-N items, under an "Invalid JSON-LD syntax" heading), and labels a wrong-shape value as invalid rather than missing. Closes #463 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/json-ld-valid-463
branch
from
October 6, 2026 00:49
2a3b502 to
1e6e2c6
Compare
This was referenced Oct 6, 2026
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.
Closes #463
What was wrong
schema/json-ld-validtypedimage(Article, Product, LocalBusiness, Recipe) andOrganization.logoas "a string or array of strings". schema.org's range for both isImageObject | URL, and Google documents both forms, so a nestedImageObjectwas reported as invalid. On a Nuxt site using@unhead/schema-orgit was worse: that library emits one@graphwhose nodes link by bare{"@id": ...}references, soArticle.author.name,Article.publisher.nameandArticle.publisher.logowere also reported missing although the referenced nodes carry them.The same repro surfaced three more defects in this rule:
parse-Nitem, because the parser appends validation messages toschema.errors. That also made the check's message readInvalid JSON-LD syntaxfor JSON that parsed fine.Article missing image.parsedData. A page reused from the crawl cache (304, hash match) keeps the previous release's verdicts, so upgrading would not have cleared the false positive until the page changed or--refreshwas passed.The fix
packages/parser/src/schema/validator.ts: newurlOrImageproperty type forimageandlogo. It accepts a URL string, anImageObject(or subtype, schema.org IRI prefixes allowed) with aurlorcontentUrl, an{"@id"}reference, or an array of these. Numbers, booleans, objects of another@type,{}and anImageObjectwith no URL stay invalid.author.name,publisher.name,publisher.logo,offers.*) now read every description of the node's@idon the page, across@graphs and script blocks. A field given by any description counts. A bare reference to an id nothing on the page describes is checked as written, so it still reports. The index walk is iterative (30k-deep nesting tested).packages/rules/src/schema/json-ld-valid.ts: re-validatesschemas.allat audit time, falling back to the stored issues only when the parsed schemas were not kept. Drops theValidation:duplicates from the parse-error items (real parse errors keep theirparse-Nids), and labelsinvalidissues<type> has an invalid <property>. Item ids are unchanged.docs/rules/schema/json-ld-valid.mdx).Cloud note, filed as #474: on a page that still fails this check for another reason (the repro's
publisher.logo), the oldArticle:imageand the duplicateparse-Nfindings stay open as carried findings until the page passes.merge-corecarries unmatched prior items while the page is still in the check's failing set. A page that now passes, such as the unhead one, resolves them.Scope note:
thumbnailUrlkeeps its string-only check, because its schema.org range isURL. The remaining places where the validator is stricter than Google are filed as #469: single values where it wants arrays,AggregateOffer, andpublisherbeing required.Evidence (CLI from source,
--http -f json --refresh, local fixtures)Issue repro page, before:
{"status": "fail", "message": "Invalid JSON-LD syntax", "items": [ {"id": "Article:image", "label": "Article missing image"}, {"id": "Article:publisher.logo", "label": "Article missing publisher.logo"}, {"id": "parse-0", "label": "Validation: Article.image must be a string or array of strings"}, {"id": "parse-1", "label": "Validation: Article.publisher.logo is required"}]}After (the
publisher.logofinding is genuine, and the issue says it is unrelated):{"status": "fail", "message": "Schema.org validation errors detected", "items": [ {"id": "Article:publisher.logo", "label": "Article missing publisher.logo"}]}An
@unhead/schema-org-shaped page (Organization identity +#logoImageObject + WebSite + WebPage + Article + ImageObject + Person, linked by{"@id"}), before:{"status": "fail", "message": "Invalid JSON-LD syntax", "items": [ {"id": "Article:author.name"}, {"id": "Article:image"}, {"id": "Article:publisher.logo"}, {"id": "Article:publisher.name"}, {"id": "Organization:logo"}, {"id": "parse-0"}, {"id": "parse-1"}, {"id": "parse-2"}, {"id": "parse-3"}, {"id": "parse-4"}]}After: no
schema/json-ld-validfinding (check passes).Cache reuse: the Nuxt page was crawled by the OLD code, then re-audited by the new code WITHOUT
--refresh. The crawl stats showpagesUnchanged: 1, cacheHitsByReason: {"304": 1}, and the reused page's storedparsedDatastill holds 5 stale_validationIssues. The check passes because the rule re-validates.Tests
packages/rules/tests/json-ld-valid.test.ts(35 tests) covers:@iddescriptions in both orders, deep nesting;schemaCollectionFromJSON.20 of these fail on
main.schema-graph-flattening,schema-entity-rules,apps/cli/tests/graph/extractors/schema,parse-page,audit-engine/tests/complete-store-parity.tsgo --noEmitclean inpackages/parserandpackages/rules(and the new test file). oxlint clean on the changed files.[email protected] check --strictpasses.Changelog suggestion
schema/json-ld-validaccepts anImageObject(or an{"@id"}reference) forimageandlogo, resolves@idreferences across the page's JSON-LD so@unhead/schema-org(Nuxt) pages validate clean, and no longer repeats validation errors under "Invalid JSON-LD syntax". Thanks @deniskern (schema/json-ld-valid: nested ImageObject in Article.image is reported as invalid #463)