Skip to content

Fix home page JSON-LD crashing structured-data readers#19

Open
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/jsonld-graph-context
Open

Fix home page JSON-LD crashing structured-data readers#19
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/jsonld-graph-context

Conversation

@posthog

@posthog posthog Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

The home page injected its schema.org JSON-LD as a bare top-level array (JSON.stringify([organizationJsonLd, productJsonLd, faqJsonLd])). Each object carried its own @context, but the array itself had none, so any consumer that treats the parsed JSON-LD as a single object reads r["@context"]undefined and crashes calling .toLowerCase() on it.

This wraps the three entities in a single @graph with one top-level @context, and drops the now-redundant per-object @context in seo.ts. This both removes the crash trigger and produces a more standard structured-data shape (a small SEO correctness gain).

Why

Error tracking captured an unhandled TypeError: undefined is not an object (evaluating 'r["@context"].toLowerCase') on https://amend.sh/ (Safari 26.3, 2026-06-06). The crashing code is an injected third-party JSON-LD reader (browser extension / structured-data reader), but the bare-array shape is what triggers it.


Created with PostHog Code from an inbox report.

The home page injected its JSON-LD as a bare top-level array, so any
consumer treating the parsed structured data as a single object read
`undefined["@context"]` and crashed. Wrap the three entities in a
`@graph` with one top-level `@context` and drop the now-redundant
per-object `@context`.

Generated-By: PostHog Code
Task-Id: 4d331e29-d220-4346-b6c8-43e10e90a2be
@leoisadev1 leoisadev1 marked this pull request as ready for review June 27, 2026 23:44
@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR changes the home page structured data shape.

  • Wraps the JSON-LD entities in a top-level schema.org object.
  • Emits the organization, product, and FAQ data through @graph.
  • Removes repeated @context fields from the graph nodes.

Confidence Score: 5/5

Safe to merge.

The change is narrowly scoped to structured-data serialization on the home page and no code issues were identified.

T-Rex T-Rex Logs

What T-Rex did

  • Observed the initial run where the base emitted a bare array, with IS_ARRAY true, TOP_CONTEXT undefined, CONTEXT_TOLOWERCASE_ERROR TypeError, no top-level graph, and array entity types Organization, SoftwareApplication, FAQPage.
  • Observed the subsequent run where the head emitted an object, with IS_ARRAY false, TOP_CONTEXT https://schema.org, CONTEXT_TOLOWERCASE https://schema.org, GRAPH_LENGTH 3, graph types Organization, SoftwareApplication, FAQPage, and GRAPH_ENTITY_CONTEXTS absent.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "Wrap home page JSON-LD in @graph with a ..." | Re-trigger Greptile

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.

0 participants