From d16403f65496cc94dc2839de7e38b3c3173005eb Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Wed, 2 Oct 2019 15:48:17 +0100 Subject: [PATCH] Correctly validate container contracts Change-type: patch Signed-off-by: Cameron Diver --- src/api-binder.ts | 13 +++++++------ src/application-manager.coffee | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/api-binder.ts b/src/api-binder.ts index b59a4654..99f4fc3b 100644 --- a/src/api-binder.ts +++ b/src/api-binder.ts @@ -589,12 +589,13 @@ export class APIBinder { }) .tapCatch(ContractValidationError, ContractViolationError, e => { log.error(`Could not store target state for device: ${e}`); - this.logger.logSystemMessage( - `Could not move to new release: ${e.message}`, - {}, - 'targetStateRejection', - false, - ); + // the dashboard does not display lines correctly, + // split them explcitly here + const lines = e.message.split(/\r?\n/); + lines[0] = `Could not move to new release: ${lines[0]}`; + for (const line of lines) { + this.logger.logSystemMessage(line, {}, 'targetStateRejection', false); + } }) .tapCatch( (e: unknown) => diff --git a/src/application-manager.coffee b/src/application-manager.coffee index 3f33f9f4..78ad6fed 100644 --- a/src/application-manager.coffee +++ b/src/application-manager.coffee @@ -695,7 +695,7 @@ module.exports = class ApplicationManager extends EventEmitter _.each app.services, (s) -> if s.contract? try - validateContract(s) + validateContract(s.contract) catch e throw new ContractValidationError(s.serviceName, e.message) serviceContracts[s.serviceName] = s.contract