Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Select Error: invalid input value for enum with defaultValue

default discord avatar
kethan_1last year
7

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 enum

that occurs when using a defaultValue still occuring

  • default discord avatar
    rilromlast year

    Could you check if the error still occurs on a fresh DB?

  • default discord avatar
    ieva.jaksaitytelast year

    I would check what rules are applied inside database. Sometimes there are new indexes or validation rules that conflicts with new rules in admin.

  • default discord avatar
    kethan_1last year

    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.

  • default discord avatar
    rilromlast year

    Out of curiousity could you try

    defaultValue: () => 'open'

    on a fresh DB.

  • default discord avatar
    kethan_1last year

    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-postgres

    plugin. 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?

  • default discord avatar
    ieva.jaksaitytelast year

    maybe you have drafts/versions turned on? then the answer is yes

  • default discord avatar
    kethan_1last year

    Oh that would make a lot of sense. I do have drafts/versions turned on. Thank you for the help!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.