diff --git a/core/server/api/canary/members.js b/core/server/api/canary/members.js index b15f9705b7..8c1bc8428d 100644 --- a/core/server/api/canary/members.js +++ b/core/server/api/canary/members.js @@ -634,6 +634,11 @@ module.exports = { invalid.errors = outputErrors; + if (imported.count === 0 && importLabel) { + await models.Label.destroy(Object.assign({}, {id: importLabel.id}, frame.options)); + importLabel = null; + } + return { meta: { stats: { @@ -741,6 +746,11 @@ module.exports = { invalid.errors = outputErrors; + if (imported.count === 0 && importLabel) { + await models.Label.destroy(Object.assign({}, {id: importLabel.id}, frame.options)); + importLabel = null; + } + return { meta: { stats: { diff --git a/test/regression/api/canary/admin/members_spec.js b/test/regression/api/canary/admin/members_spec.js index f083978128..1f8aa4fa4d 100644 --- a/test/regression/api/canary/admin/members_spec.js +++ b/test/regression/api/canary/admin/members_spec.js @@ -451,6 +451,8 @@ describe('Members API', function () { should.equal(jsonResponse.meta.stats.invalid.errors.length, 1); jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Missing Stripe connection'); + + should.not.exist(jsonResponse.meta.import_label); }); }); @@ -485,6 +487,8 @@ describe('Members API', function () { jsonResponse.meta.stats.invalid.errors[3].message.should.equal('Validation failed for \'complimentary_plan\''); jsonResponse.meta.stats.invalid.errors[3].count.should.equal(1); + + should.not.exist(jsonResponse.meta.import_label); }); }); @@ -510,6 +514,8 @@ describe('Members API', function () { should.equal(jsonResponse.meta.stats.invalid.errors.length, 1); jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Member already exists'); jsonResponse.meta.stats.invalid.errors[0].count.should.equal(1); + + should.exist(jsonResponse.meta.import_label); }); });