Skip to content

plugin-seo & ui: PreviewField throws "circular structure to JSON" #16786

@codeplott

Description

@codeplott

Describe the Bug

On the SEO tab of a document that contains an array field with a custom RowLabel component and at least one row with a populated relationship, Payload throws:

  TypeError: Converting circular structure to JSON
      --> starting at object with constructor 'BasePayload'
      |     property 'db' -> object with constructor 'Object'
      --- property 'payload' closes the circle

It throws inside PreviewComponent's useEffect while building the body for POST /api/plugin-seo/generate-url. MetaTitleField's Auto-generate button does the same
thing against /api/plugin-seo/generate-title.

reduceToSerializableFields in @payloadcms/ui calls a shallow sanitizeField helper that strips customComponents and validate only from the top-level of each field entry. Array form state has the same keys inside rows[i], and those still hold the rendered RowLabel tree.

Link to the code that reproduces this issue

https://github.com/codeplott/payloadcms-rowlabel-plugin-seo

Reproduction Steps

Clone: https://github.com/codeplott/payloadcms-rowlabel-plugin-seo

  1. Create a page, give it a title and slug, save.
  2. Add one entry to the links array, set label, pick the page itself (or any other page) for reference, save.
  3. Reload the edit view.
  4. The runtime error overlay shows Converting circular structure to JSON ... BasePayload ... db ... payload.
  5. The SEO Preview URL stays at https://... instead of what generateURL would produce. Clicking the MetaTitle "Auto-generate" button throws the same error.

Which area(s) are affected?

plugin: seo

Environment Info

Binaries:
    Node: 24.16.0
    npm: 11.15.0
    pnpm: 10.33.4
  Relevant Packages:
    payload: 3.85.0
    next: 16.2.6
    @payloadcms/db-mongodb: 3.85.0
    @payloadcms/graphql: 3.85.0
    @payloadcms/next/utilities: 3.85.0
    @payloadcms/plugin-seo: 3.85.0
    @payloadcms/richtext-lexical: 3.85.0
    @payloadcms/translations: 3.85.0
    @payloadcms/ui/shared: 3.85.0
    react: 19.2.6
    react-dom: 19.2.6
  Operating System:
    Platform: darwin
    Arch: arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: seo@payloadcms/plugin-seostatus: needs-triagePossible bug which hasn't been reproduced yetv3

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions