Every evening when the cron kicks off the user encounters the following error because the time format given to the database is incorrect:
/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/packets/packet.js:738
const err = new Error(message);
^
Error: delete from `strapi_history_versions` where (`created_at` < '2024-07-07T21:00:00.024Z') - Incorrect datetime value: '2024-07-07T21:00:00.024Z' for column 'created_at' at row 1
at Packet.asError (/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/packets/packet.js:738:17)
at Query.execute (/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/commands/command.js:29:26)
at Connection.handlePacket (/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/connection.js:481:34)
at PacketParser.onPacket (/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/connection.js:97:12)
at PacketParser.executeStart (/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/app/work/strapi/build_images/-snip-/node_modules/mysql2/lib/connection.js:104:25)
at Socket.emit (node:events:517:28)
at Socket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9) {
code: 'ER_TRUNCATED_WRONG_VALUE',
errno: 1292,
sqlState: '22007',
sqlMessage: "Incorrect datetime value: '2024-07-07T21:00:00.024Z' for column 'created_at' at row 1",
sql: "delete from `strapi_history_versions` where (`created_at` < '2024-07-07T21:00:00.024Z')"
}
Node.js v18.20.2
error Command failed with exit code 1.
Bug report
Required System information
Describe the bug
Every evening when the cron kicks off the user encounters the following error because the time format given to the database is incorrect:
Steps to reproduce the behavior
Expected behavior
Proper datetime format used
Screenshots
N/A
Code snippets
Appears to come from
https://github.com/strapi/strapi/blob/bbe5b7f1f46249a3154695d5ecc04fc4f74793b4/packages/core/content-manager/server/src/history/services/lifecycles.ts#L174-L189
Specifically this line:
https://github.com/strapi/strapi/blob/bbe5b7f1f46249a3154695d5ecc04fc4f74793b4/packages/core/content-manager/server/src/history/services/lifecycles.ts#L182
Additional context
Related TID: 8440
Also the syntax of this cron task is incorrect, it's using the older format and should be changed to the new format see: https://github.com/strapi/strapi/pull/21407