Stale saved sort after a field becomes virtual silently hides collection documents

Open
#19,617 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@hassanabrar202 is already working on this.

Since Nov 16, 2026.

  • #19618 by @hassanabrar202 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
nextjs, postgresql, react, sqlite, typescript

Research direction

Start with the _community fixture and its browser tests linked in the issue, then trace how the saved collection-posts preference reaches the posts list query and how query errors are rendered. Run the supplied Playwright reproduction with the stale -computedValue sort. Done means the seeded post remains visible or the admin shows an actionable error that lets the user reset the invalid saved sort. A linked open pull request is already addressing this issue.

Written by the indexing model from the issue text.

Description

area: core area: ui Bug db: postgres db: sqlite Payload OSS
Describe the Bug

A saved collection sort can outlive the field's ability to be queried. After a stored field becomes virtual, Payload reuses that user's saved sort and rejects the list query. On current 3.x, the Admin Panel silently displays "No Results" even though documents exist. There is no explanation that the saved sort is invalid.

This is account-specific because the sort is stored in payload-preferences. Clearing browser cookies/cache does not repair it. An explicit valid sort in the URL restores the list.

The original report was a blank list area with the sidebar still visible on Payload 3.90.0/Postgres in production. The reproduction on current 3.x (3.93.0) shows a misleading empty list instead. Older versions derived error names from class names, while the list renderer checks err.name !== 'QueryError'; production minification is a suspected contributor to the different presentation. Current 3.x explicitly sets QueryError.name. I have not rebuilt the standalone reproduction in production mode.

Expected: A stale sort should not make existing documents appear missing. Discard the invalid ordering and use the collection's default, or show an actionable error with a way to reset the saved setting.

Link to the code that reproduces this issue

https://github.com/jenslys/payload/tree/c170f08b38/test/_community

This branch changes only the _community fixture, its generated types, and its browser tests. It does not patch Payload.

Reproduction Steps
  1. Check out repro/3x-stale-list-sort in the linked fork and run pnpm install.

  2. Start the fixture with a disposable SQLite database:

    PAYLOAD_DATABASE=sqlite SQLITE_URL=file:./stale-sort-reproduction.db pnpm dev _community
    

    The repository's test runner can clear the test database on startup.

  3. Open /admin/collections/posts on the printed localhost origin. The normal development user signs in automatically.

  4. The list shows "No Results", despite the seeded example post.

  5. Open /admin/collections/posts?sort=title. The same post becomes visible.

The seed creates this database-backed preference for the development user:

{
  "key": "collection-posts",
  "value": {
    "sort": "-computedValue"
  }
}

computedValue is now a text field with virtual: true. The seed represents a preference saved while that field was still stored, avoiding two builds and a schema migration just to reproduce the stale state.

The underlying query rejection is:

The following path cannot be queried: computedValue
Verified browser regression
pnpm exec playwright install chromium
PAYLOAD_DATABASE=sqlite SQLITE_URL=file:./stale-sort-reproduction.db PORT=3187 \
  pnpm test:e2e _community --workers=1

Observed result on upstream 3.x at 2a1a9c83d9:

  • Pass: Explicit valid sort restores the seeded post.
  • Fail: Loading the list with the stale saved sort does not show the existing post. The assertion times out, and the browser snapshot shows "No Results".
  • Both tests successfully create and delete their own preference through the authenticated preference endpoint.

The failing assertion intentionally specifies the expected recovery behavior; the branch is a reproduction, not a fix.

Which area(s) are affected?

area: ui, area: core, db: sqlite, db: postgres

Environment Info
Reproduction:
  Payload packages: 3.93.0 (upstream 3.x checkout at 2a1a9c83d9)
  Next.js: 16.4.1
  React: 19.2.9
  Node.js: 22.23.5
  pnpm: 11.28.6
  Database: SQLite
  Playwright: 1.63.0, Chromium
  OS: macOS, arm64

Original production report:
  Payload packages: 3.90.0
  Next.js: 16.4.3
  Database: Postgres

Related: #12886 fixed enabling sort headers on virtual fields. This case concerns an already persisted sort that became invalid after a schema change; it does not require clicking a virtual field's sort header.

Dominant language
TypeScript
Stars
45.8k
Forks
4.4k
Avg merge
2d 16h
Merged PRs (30d)
251

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from payloadcms/payload

All issues in payloadcms/payload

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.