payloadcms / payloadcms/payload

lock-file query failure with large numeric-string text ID with postgresql

Open
#14,505 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

What: a Posts-like collection where the ID is stored as text but holds a large numeric string (e.g. "9223372036854775808" or similar).
Steps:
Create the collection with a text ID field.
Insert a document whose ID is a very large numeric string.
Run the query that touches the lock-file path (or run the failing payload command).
Observe the query/lock-file failure.
error:
caused by: error: value "17624247126325972" is out of range for type integer

ERROR: Failed query: select distinct "payload_locked_documents"."id", 
"payload_locked_documents"."created_at", "payload_locked_documents"."created_at" 
from "payload_locked_documents" 
left join "payload_locked_documents_rels" "91dad9ac_4d71_47ad_b702_0d1846ce772d" 
on ("payload_locked_documents"."id" = "91dad9ac_4d71_47ad_b702_0d1846ce772d"."parent_id" 
and "91dad9ac_4d71_47ad_b702_0d1846ce772d"."path" like $1) 
where (
  ("91dad9ac_4d71_47ad_b702_0d1846ce772d"."posts_id" = $2 or 
   "91dad9ac_4d71_47ad_b702_0d1846ce772d"."media_id" = $3 or 
   "91dad9ac_4d71_47ad_b702_0d1846ce772d"."users_id" = $4) 
  and "91dad9ac_4d71_47ad_b702_0d1846ce772d"."posts_id" is not null 
  and "payload_locked_documents"."updated_at" > $5
) 
order by "payload_locked_documents"."created_at" desc 
limit $6

params: 
  document,
  0017624247126325973,   # <- Text parameter for posts_id (works)
  17624247126325972,     # <- Integer parameter for media_id (causes issue)
  17624247126325972,     # <- Integer parameter for users_id (causes issue)
  2025-11-06T10:21:02.988Z,
  10
Link to the code that reproduces this issue

https://github.com/ma-joel/payload-string-id-bug/commit/876087ee9ffe8532f0c64caa21636c3339d199f9

Reproduction Steps

The bug reproduction environment has been configured in test/_community/ with:

  1. Custom Field: fields/snowflakeId.ts - Creates text-based IDs with large numeric strings
  2. Test Collection: collections/Posts/index.ts - Modified to use the custom text ID
  3. Updated Config: Posts collection now uses text ID while Users and Media use integer IDs
Which area(s) are affected? (Select all that apply)

area: core

Environment Info
Binaries:
  Node: 23.11.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.11.0
Relevant Packages:
  payload: 3.61.1
  next: 15.4.4
  @payloadcms/db-postgres: 3.61.1
  @payloadcms/drizzle: 3.61.1
  @payloadcms/email-nodemailer: 3.61.1
  @payloadcms/graphql: 3.61.1
  @payloadcms/next/utilities: 3.61.1
  @payloadcms/payload-cloud: 3.61.1
  @payloadcms/richtext-lexical: 3.61.1
  @payloadcms/translations: 3.61.1
  @payloadcms/ui/shared: 3.61.1
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025
  Available memory (MB): 7923
  Available CPU cores: 4

Contributor guide

Open the contributing guide

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.

Research direction

Start with test/_community/fields/snowflakeId.ts and test/_community/collections/Posts/index.ts, then run the linked reproduction or failing payload command. Trace how the lock-file query builds parameters for the text and integer IDs. Done means the reproduction passes without an out-of-range PostgreSQL error, with a regression test covering the mixed ID types.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.