8000 Invalid input {} instead of ID error when creating/updating a document with a localized media field. · Issue #12463 · payloadcms/payload · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Invalid input {} instead of ID error when creating/updating a document with a localized media field. #12463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
agi-v0 opened this issue May 20, 2025 · 1 comment
Assignees

Comments

@agi-v0
Copy link
agi-v0 commented May 20, 2025

Describe the Bug

Essentially creating or updating a document fails if it has a specific block type(s). When we first pushed to prod, the faulty blocks worked as expected - and saving and publishing was perfectly fine.

The error message from the logger says:

ERROR: invalid input syntax for type integer: "{}" err: { "type": "DatabaseError", "message": "invalid input syntax for type integer: \"{}\"", "stack": error: invalid input syntax for type integer: "{}" ..., "length": 140, "name": "error", "severity": "ERROR", "code": "22P02", "where": "unnamed portal parameter $1 = '...'", "file": "numutils.c", "line": "232", "routine": "pg_strtoint32" }

and from the database logs I can see it is related to an undefined id indeed:
postgres15.8 | 2025-05-20 16:20:32.040 UTC [121] ERROR: invalid input syntax for type integer: "{}" postgres15.8 | 2025-05-20 16:20:32.040 UTC [121] CONTEXT: unnamed portal parameter $1 = '...' postgres15.8 | 2025-05-20 16:20:32.040 UTC [121] STATEMENT: insert into "callToActionBlock_locales" ("badge_label", "rich_text", "media_id", "id", "_locale", "_parent_id") values (default, default, $1, default, $2, $3), (default, default, $4, default, $5, $6) returning "badge_label", "rich_text", "media_id", "id", "_locale", "_parent_id"
The error started randomly occurring in production and doesn't reproduce locally with a fresh database neither in dev or on a preview build. The only I could replicate it locally was through dumping the production database. It hasn't resolved

Looking at the erroneous blocks (Features and Call to action), which you can view in src/blocks, I'm guessing it might be related to the localized media fields present in their schema. Commenting out the localized:true in the 'blockImage' field in the 'Features' block for example resolves the create/update error. You would have to create a migration and run it to see that.

Please pardon me if the error description is wrong or if it turns out to be a mistake on my part. Thanks for looking into this.

Link to the code that reproduces this issue

https://github.com/agi-v0/payload/tree/bug

Reproduction Steps

  1. Clone repo (ensure you're on the 'bug' branch).
  2. run docker compose up to set up db.
  3. Set up your .env based on env.example (copy the same DATABASE_URI)
  4. run bash dump_to_local.sh
  5. Launch dev server (turbopack works nicely if you prefer).
  6. You should be able to auto signin into a user from the dumped database.
  7. Go into any 'Pages' doc > go to 'Layout' > add a 'Features' block or a 'Call to Action' block and hit publish.
  8. Remove any of those blocks and add any other ("Featured Apps" or "Gallery") - should work fine.

Optionally:
9. Comment out the localize: true prop of the blockImage field in the Features block, then create and run a migration, then refresh the admin panel and try adding a features block: should work fine.

Which area(s) are affected? (Select all that apply)

db-postgres, db-vercel-postgres

Environment Info

Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.6.5
Relevant Packages:
  payload: 3.38.0
  next: 15.3.2
  @payloadcms/db-postgres: 3.38.0
  @payloadcms/email-nodemailer: 3.38.0
  @payloadcms/email-resend: 3.38.0
  @payloadcms/graphql: 3.38.0
  @payloadcms/live-preview: 3.38.0
  @payloadcms/live-preview-react: 3.38.0
  @payloadcms/next/utilities: 3.38.0
  @payloadcms/payload-cloud: 3.38.0
  @payloadcms/plugin-cloud-storage: 3.38.0
  @payloadcms/plugin-form-builder: 3.38.0
  @payloadcms/plugin-nested-docs: 3.38.0
  @payloadcms/plugin-redirects: 3.38.0
  @payloadcms/plugin-search: 3.38.0
  @payloadcms/plugin-seo: 3.38.0
  @payloadcms/richtext-lexical: 3.38.0
  @payloadcms/storage-s3: 3.38.0
  @payloadcms/translations: 3.38.0
  @payloadcms/ui/shared: 3.38.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 12
@agi-v0 agi-v0 added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels May 20, 2025
@github-actions github-actions bot removed the validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. label May 20, 2025
@agi-v0
Copy link
Author
agi-v0 commented May 20, 2025

It's worth noting that the hero schema also contains a localized media field but it isn't throwing any errors on create / publish.

@r1tsuu r1tsuu self-assigned this May 23, 2025
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0