Invalid input {} instead of ID error when creating/updating a document with a localized media field. · Issue #12463 · payloadcms/payload · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Set up your .env based on env.example (copy the same DATABASE_URI)
run bash dump_to_local.sh
Launch dev server (turbopack works nicely if you prefer).
You should be able to auto signin into a user from the dumped database.
Go into any 'Pages' doc > go to 'Layout' > add a 'Features' block or a 'Call to Action' block and hit publish.
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)
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
bash dump_to_local.sh
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
The text was updated successfully, but these errors were encountered: