Relationship (many) field with no max/min defined fails with more than 10 items. Setting a "max" doesn't change the outcome.
Any solution on that?
This doesn't sound like normal behavior. Can you expand upon what you're seeing? What is the failure?
Here is the code:
{
label: { fr: "Accessoires", en: "Accessories" },
fields: [
{
name: "accessories",
label: {
en: "Accessories",
fr: "Accessoires",
},
type: "relationship",
relationTo: "products",
hasMany: true,
filterOptions: ({ data }) => {
const typedData = data as Product;
return {
and: [
{
brand: {
equals: typedData.brand,
},
},
{
isBrandAccessory: {
equals: true,
},
},
],
};
},
},
],
},Here is the error:
[2023-06-02T15:37:11]
[15:37:11] ERROR (payload): ValidationError: Le champ suivant n'est pas valide : accessories
[2023-06-02T15:37:11]
at beforeChange (/workspace/node_modules/payload/dist/fields/hooks/beforeChange/index.js:31:15)
[2023-06-02T15:37:11]
at runMicrotasks (<anonymous>)
[2023-06-02T15:37:11]
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-06-02T15:37:11]
at async updateByID (/workspace/node_modules/payload/dist/collections/operations/updateByID.js:143:18)
[2023-06-02T15:37:11]
at async updateByIDHandler (/workspace/node_modules/payload/dist/collections/requestHandlers/updateByID.js:19:21)
[2023-06-02T14:38:20]
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-06-02T14:38:20]
at async updateByID (/workspace/node_modules/payload/dist/collections/operations/updateByID.js:143:18)
[2023-06-02T14:38:20]
at async updateByIDHandler (/workspace/node_modules/payload/dist/collections/requestHandlers/updateByID.js:19:21)I have no custom hooks installed on this collection though, and the relationship is self referencing
So it throws a validation error when you select more than 10 relationships?
Yes exactly, but I can’t identify why
Interesting, if you can create a minimally reproducible config, this would help narrow down any potential bugs. For instance, remove the self-reference and
filterOptionsto see if the issue persists. If so let’s open a ticket on GitHub. There’s a
tests/_communityfolder in the repo for this exact purpose, if needed.
(sorry for the delay)
here you go for the sandbox.
The source of the problem is the
filterOptionsmethod.
You can go to
Examples->
The main testIt has now 10 associations, if you add one more, the bug appears.
I forgot that the content is not kept between session. I'll create a seeding option
I made the issue with the reproduction steps
This is great, thank you!!
We’re on it
Thanks!
Star
Discord
online
Get dedicated engineering support directly from the Payload team.