Skip to content

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

@ma-joel

Description

@ma-joel

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

ma-joel@876087e

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions