From bb9254f4a7d44aed712463e3c418e915129a43f9 Mon Sep 17 00:00:00 2001 From: dcaputo-harmoni Date: Mon, 30 Oct 2023 00:29:20 -0400 Subject: [PATCH] Fix handling of release / contract param as string Change-type: patch --- src/features/ci-cd/hooks/release-versioning.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/features/ci-cd/hooks/release-versioning.ts b/src/features/ci-cd/hooks/release-versioning.ts index a27ca2829..d3676159d 100644 --- a/src/features/ci-cd/hooks/release-versioning.ts +++ b/src/features/ci-cd/hooks/release-versioning.ts @@ -164,6 +164,16 @@ hooks.addPureHook('POST', 'resin', 'release', { const custom = request.custom as CustomObjectBase; // Releases are by final by default custom.is_final ??= true; + // Handle case where contracts provided as stringified object + if (typeof request.values.contract === 'string') { + try { + request.values.contract = JSON.parse(request.values.contract); + } catch (err) { + throw new BadRequestError( + 'Invalid contract format. Must be a valid JSON object.', + ); + } + } }, POSTRUN: async ({ api, request, result: releaseId, tx }) => { const custom = request.custom as CustomObjectBase;