Skip to content

Filtering on a join field in filterOptions crashes #12768

Closed
@JesperWe

Description

@JesperWe

Describe the Bug

In my repro project I want to filter out the media files relevant to a master product.

Here is the relevant code, which uses a join field to filter.

This filter crashes with:

POST /admin/collections/productmaster/1 500 in 36ms
 ⨯ [Error [APIError]: Cannot find field for path at undefined] 
{
  data: null,
  isOperational: true,
  isPublic: false,
  status: 500,
  digest: '1298757053',
  [cause]: null
}

The HTTP request looks ok to me:

[
  {
    "name": "render-list",
    "args": {
      "allowCreate": true,
      "collectionSlug": "media",
      "disableBulkDelete": true,
      "disableBulkEdit": true,
      "disableQueryPresets": "$undefined",
      "drawerSlug": "list-drawer_1_«r1c»",
      "enableRowSelections": "$undefined",
      "overrideEntityVisibility": true,
      "query": {
        "where": {
          "used_by_product": {
            "in": [
              1,
              2
            ]
          },
          "id": {
            "not_in": []
          }
        }
      }
    }
  }
]

Link to the code that reproduces this issue

https://github.com/JesperWe/join-filter.git

Reproduction Steps

In the repro app:

  1. Create a Product
  2. Add a media file to Product
  3. Create a Productmaster with a relation to the product
  4. Attempt to add a hero image to the Productmaster
  5. The selection UI does not appear as expected, error is reported on backend

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Binaries:
  Node: 20.11.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 10.11.1
Relevant Packages:
  payload: 3.42.0
  next: 15.3.0
  @payloadcms/email-nodemailer: 3.42.0
  @payloadcms/graphql: 3.42.0
  @payloadcms/next/utilities: 3.42.0
  @payloadcms/payload-cloud: 3.42.0
  @payloadcms/richtext-lexical: 3.42.0
  @payloadcms/translations: 3.42.0
  @payloadcms/ui/shared: 3.42.0
  react: 19.1.0
  react-dom: 19.1.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions