Skip to content

DELETE /api/payload-preferences/:key returns 500 when the key does not exist (4.0.0-beta.4, Postgres) #19044

Description

@relative23

Describe the Bug

Tested on 4.0.0-beta.4, Postgres adapter, signed in as an admin:

  • GET /api/payload-preferences/<missing-key> → 200 {"message":"Not Found","value":null}
  • DELETE /api/payload-preferences/<missing-key> → 500 {"errors":[{"message":"Something went wrong."}]}
  • DELETE of an existing key → 200, row deleted

The log shows a DrizzleQueryError from @payloadcms/drizzle deleteOne: missing FROM-clause entry for table "<uuid>".

Likely cause: in packages/drizzle/src/deleteOne.ts (same on main), when selectDistinct with the joins finds no row, the else branch runs findFirst with the same where, which refers to the join of the user relationship, but without the joins.

Expected: 404 (or a 200 no-op), not 500.

Not checked: other database adapters.

Link to the code that reproduces this issue

Not public. The steps below need only the Postgres adapter and a signed-in user.

Reproduction Steps

  1. Sign in to the admin (or POST /api/users/login).
  2. GET /api/payload-preferences/does-not-exist → 200, value: null.
  3. DELETE /api/payload-preferences/does-not-exist → 500.

Which area(s) are affected?

area: core, db: postgres

Environment Info

payload: 4.0.0-beta.4
@payloadcms/db-postgres: 4.0.0-beta.4
next: 16.4.2
Node.js: 24.19.0
PostgreSQL: 18

Activity

  1. added
    area: core
    db: postgres
    on Oct 24, 2026
  2. added
    area: core
    and removed
    area: core
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPayload OSSarea: coredb: postgres

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions