diff --git a/src/versions/saveCollectionVersion.ts b/src/versions/saveCollectionVersion.ts index 05ae81db45..85f0cd7983 100644 --- a/src/versions/saveCollectionVersion.ts +++ b/src/versions/saveCollectionVersion.ts @@ -42,6 +42,13 @@ export const saveCollectionVersion = async ({ }); if (latestVersion) { + // If the latest version is a draft, no need to re-save it + // Example: when "promoting" a draft to published, the draft already exists. + // Instead, return null + if (latestVersion?.version?._status === 'draft') { + return null; + } + version = latestVersion.version; version = JSON.parse(JSON.stringify(version)); version = sanitizeInternalFields(version); diff --git a/src/versions/saveGlobalVersion.ts b/src/versions/saveGlobalVersion.ts index e0598b8d04..b7c2e48851 100644 --- a/src/versions/saveGlobalVersion.ts +++ b/src/versions/saveGlobalVersion.ts @@ -37,6 +37,13 @@ export const saveGlobalVersion = async ({ }); if (latestVersion) { + // If the latest version is a draft, no need to re-save it + // Example: when "promoting" a draft to published, the draft already exists. + // Instead, return null + if (latestVersion?.version?._status === 'draft') { + return null; + } + version = latestVersion.version; version = JSON.parse(JSON.stringify(version)); version = sanitizeInternalFields(version);