From ed051e15476f427414e77cdaa73ff730f01580f1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 8 Nov 2021 13:06:25 +0100 Subject: [PATCH] fix revert on unpublished app --- packages/server/src/api/controllers/dev.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index c43de7f553..ed58b8048b 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -82,6 +82,13 @@ exports.revert = async ctx => { const db = new CouchDB(productionAppId, { skip_setup: true }) const info = await db.info() if (info.error) throw info.error + const deploymentDoc = await db.get(DocumentTypes.DEPLOYMENTS) + if ( + !deploymentDoc.history || + Object.keys(deploymentDoc.history).length === 0 + ) { + throw new Error("No deployments for app") + } } catch (err) { return ctx.throw(400, "App has not yet been deployed") }