Skip to content

fix: fix findCustomID to prevent early escape #13010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

slavanossar
Copy link
Contributor

@slavanossar slavanossar commented Jul 2, 2025

What?

Don't return a truthy value for group-like fields and discontinue field traversal within the findCustomID callback function.

Why?

Currently, there is a bug that prevents customIDType being set correctly when the custom ID field is placed after a tabs field that includes a tab with a name, since the first condition will return true and prevent further field traversal. This bug only becomes apparent when using a number type for the custom ID field, since customIDType is undefined so the typing defaults to text (breaking field validation, as well as <Document> views where findByID is passed a string instead of a number)

Here's an example of a CollectionConfig that would be affected:

const MyCollection: CollectionConfig = {
  slug: 'myCollection',
  fields: [
    {
      type: 'tabs',
      tabs: [
        {
          label: 'Tab',
          fields: [
            // ...
          ]
        },
        {
          name: 'namespacedTab',
          fields: [
            // ...
          ]
        }
      ]
    },
    {
      name: 'id',
      type: 'number',
      required: true,
      unique: true,
      admin: {
        readOnly: true,
      }
    }
  ]
}

See this Discord thread for additional context.

How?

Just use an undefined return, like the subsequent check for fieldAffectsData.

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

Successfully merging this pull request may close these issues.

1 participant