Skip to content

Account view crashes with "Cannot use 'in' operator to search for 'hidden' in undefined" on a minimal auth collection (3.89.0, Next 16.3.4) #18162

Open

Description

@pattoli

Describe the Bug

After creating the first user, Payload redirects to /admin/account. That view throws during server render and the app's error boundary catches it. Every other admin view (collections list, list view, edit, create) renders fine for the same user.

Stack (production, Vercel, Node 22):

TypeError: Cannot use 'in' operator to search for 'hidden' in undefined
    at fieldIsHiddenOrDisabled (payload/dist/fields/config/types.js:41)
    at renderField (@payloadcms/ui/dist/forms/fieldSchemasToFormState/renderField.js:153)   // fieldIsHiddenOrDisabled(clientField)
    at addFieldStatePromise → iterateFields → buildFormState
    at Account view (@payloadcms/next/dist/views/Account/index.js:83, renderAllFields: true, schemaPath: collectionConfig.slug)

clientField comes from clientFieldSchemaMap.get(schemaPath) and is undefined for at least one field the server-side iteration visits, so the hidden/disabled check dereferences undefined.

Link to the code that reproduces this issue

Auth collection with no custom fields:

export const Users: CollectionConfig = {
  slug: "users",
  auth: true,
  admin: { useAsTitle: "email" },
  fields: [],
};

Config: postgresAdapter, lexicalEditor(), sharp, custom routes.admin, one other collection (posts, plain text/textarea/date/select/richText fields). Import map regenerated for 3.89.0. Single copy of every @payloadcms/* package (npm ls deduped).

Reproduction Steps

  1. Fresh database, config above, payload + @payloadcms/next + @payloadcms/ui + @payloadcms/db-postgres + @payloadcms/richtext-lexical all 3.89.0, next 16.3.4.
  2. Open the admin, complete /create-first-user.
  3. Land on /admin/account → server error above. Navigating to /admin/collections/users/<id> or /admin/collections/posts works.

Which area(s) are affected?

area: ui

Environment Info

payload 3.89.0, @payloadcms/next 3.89.0, @payloadcms/ui 3.89.0, @payloadcms/db-postgres 3.89.0, @payloadcms/richtext-lexical 3.89.0
next 16.3.4 (Turbopack), react 19.2.4
node 22 (Vercel serverless), postgres (Supabase)

Activity

  1. added
    area: ui
    on Sep 11, 2026
  2. bouchetcyril-commits commented on Sep 29, 2026

    @bouchetcyril-commits

    Same crash on 3.90.2 (Next 16.3.6, Vercel, Supabase Postgres), and not only on /admin/account: after completing /create-first-user, the create and edit views of the auth collection (/admin/collections/users/create, /admin/collections/users/<id>) rendered only the header, with the same stack (fieldIsHiddenOrDisabled <- renderField). Other collections were fine.

    The trigger we found is consistent with #18168: CreateFirstUserClient's onChange calls getFormState with no user and without skipClientConfigAuth, so buildFormState hands getClientSchemaMap the unauthenticated client config (auth collection reduced to { slug, auth }), and the resulting map is cached per slug for the life of the process. The server render of /create-first-user itself uses skipClientConfigAuth: true, so in a single process the full map usually gets cached first; the bug appears when one of those anonymous form-state requests is the first to reach a fresh instance, which is common on serverless. A redeploy made it disappear for us.

    We reproduced it deterministically with two next start instances of the same production build on one empty database (type in the create-first-user form on instance A, replay the resulting form-state request on instance B, then open the users views on B). A local patch that stops caching the map built from the unauthenticated config (same idea as #18168) fixes it.

    (Investigation done with Claude Code.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugarea: ui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions