In a collection, the following works:
{
name: "status",
type: "select",
options: [
{ label: "Open", value: "open" },
{ label: "Closed", value: "closed" },
{ label: "Draft", value: "draft" },
],
required: true,
},but the following (adding defaultValue) does not:
{
name: "status",
type: "select",
options: [
{ label: "Open", value: "open" },
{ label: "Closed", value: "closed" },
{ label: "Draft", value: "draft" },
],
defaultValue: "open",
required: true,
},and results in this error:
Internal error: error: invalid input value for enum enum_job_postings_status: "open"Apparently even the one that pushes to the DB (the one without defaultValue) doesn't work when adding an element to the collection in the admin dashboard, resulting in this error:
with the
invalid input value for enumthat occurs when using a defaultValue still occuring
Could you check if the error still occurs on a fresh DB?
I would check what rules are applied inside database. Sometimes there are new indexes or validation rules that conflicts with new rules in admin.
I don't believe so. I deleted all tables related to job postings and the issue still persisted. I'm not the most familiar with Postgres or Supabase, so I might have missed something though.
The error still occurs in a fresh DB.
Out of curiousity could you try
defaultValue: () => 'open'on a fresh DB.
This results in:
[ Server ] Error: insert or update on table "payload_locked_documents_rels" violates foreign key constraint "payload_locked_documents_rels_job_postings_fk"Oh, let me try this in a fresh DB.
This works on a fresh DB.
Nope. When opening up the create element in collection page in the admin dashboard, the resulting error is:
ERROR: invalid input value for enum enum_job_postings_status: "open"I am using Payload v3.5 with Supabase and the
@payloadcms/db-postgresplugin. Sorry for not providing this information earlier.
The issue seems to have been caused by the name of the field. When I change it to anything other than "status", the schema is properly pushed and everything works.
Is status a reserved name?
maybe you have drafts/versions turned on? then the answer is yes
Oh that would make a lot of sense. I do have drafts/versions turned on. Thank you for the help!
Star
Discord
online
Get dedicated engineering support directly from the Payload team.