Skip to content

Authenticated me endpoint ignores the draft URL search parameter #18072

Open
deepshekhardas/payload
#16

Description

@jashkarangiya

Describe the Bug

The authenticated REST me handler ignores a draft value supplied through req.searchParams when req.query.draft is absent.

packages/payload/src/auth/endpoints/me.ts currently initializes both search-parameter fallbacks from depth:

const depthFromSearchParams = searchParams.get('depth')
const draftFromSearchParams = searchParams.get('depth')

As a result, a request represented as ?draft=true reaches meOperation with draft: false. This affects adapters that populate the standard URLSearchParams representation without also copying draft into req.query.

The typo is present in v3.88.0, the current 3.x branch, and current main.

Link to the code that reproduces this issue

https://github.com/jashkarangiya/payload/blob/reproduction/me-draft-search-param/packages/payload/src/auth/endpoints/me.spec.ts

Reproduction Steps

  1. Check out the linked reproduction branch and install dependencies with the repository's Node 24 / pnpm 11 toolchain.

  2. Run:

    pnpm exec vitest run --project unit packages/payload/src/auth/endpoints/me.spec.ts
  3. Observe that the test fails because meOperation receives draft: false even though the request has new URLSearchParams('draft=true').

Expected: the handler reads searchParams.get('draft') and passes draft: true.

Which area(s) are affected?

area: core

Environment Info

Payload: 3.88.0 (also reproduced on current 3.x and main)
Node.js: 24.15.0+
pnpm: 11.9.0
Framework: handler-level; reproducible without a database
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

    Bugarea: core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions