From 64e8d2b8b3142362cad2861cb1a2f99f92e48f59 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 7 Feb 2025 10:15:43 +0000 Subject: [PATCH] [history-v1] fix backup deletion for postgres projects (#23466) * [history-v1] fix backup deletion for postgres projects * [history-v1] convert historyId to string on assignment Co-authored-by: Brian Gough --------- Co-authored-by: Brian Gough GitOrigin-RevId: 5e1033972745a9b72606638f56ebf2147406cc39 --- services/history-v1/storage/lib/backupDeletion.mjs | 3 ++- .../test/acceptance/js/api/backupDeletion.test.mjs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/services/history-v1/storage/lib/backupDeletion.mjs b/services/history-v1/storage/lib/backupDeletion.mjs index b52c31a160..ef50609753 100644 --- a/services/history-v1/storage/lib/backupDeletion.mjs +++ b/services/history-v1/storage/lib/backupDeletion.mjs @@ -51,7 +51,8 @@ async function deleteProjectBackup(projectId) { throw new NotReadyToDelete('refusing to delete non-expired project') } - const historyId = deletedProject.deleterData.deletedProjectOverleafHistoryId + const historyId = + deletedProject.deleterData.deletedProjectOverleafHistoryId?.toString() if (!historyId) { throw new NotReadyToDelete( 'refusing to delete project with unknown historyId' diff --git a/services/history-v1/test/acceptance/js/api/backupDeletion.test.mjs b/services/history-v1/test/acceptance/js/api/backupDeletion.test.mjs index 72af62b1d2..46512d1b92 100644 --- a/services/history-v1/test/acceptance/js/api/backupDeletion.test.mjs +++ b/services/history-v1/test/acceptance/js/api/backupDeletion.test.mjs @@ -50,7 +50,7 @@ async function deleteProject(projectId) { } /** - * @param {string|ObjectId} historyId + * @param {number|ObjectId} historyId * @return {Promise} */ async function expectToHaveBackup(historyId) { @@ -61,7 +61,7 @@ async function expectToHaveBackup(historyId) { } /** - * @param {string|ObjectId} historyId + * @param {number|ObjectId} historyId * @return {Promise} */ async function expectToHaveNoBackup(historyId) { @@ -90,7 +90,7 @@ describe('backupDeletion', function () { }) describe('DELETE /project/:projectId', function () { - const postgresHistoryId = '1' + const postgresHistoryId = 1 const projectIdPostgres = new ObjectId('000000000000000000000001') const projectIdMongoDB = new ObjectId('000000000000000000000002') const projectIdNonDeleted = new ObjectId('000000000000000000000003')