From 5a1010331559a1ab3ab33b0f4e4b60d74cd954c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=B6ffler?= Date: Fri, 13 Dec 2024 15:19:20 +0100 Subject: [PATCH] putAdditionalParamsInBody now better guards against missing metadata --- templates/lib/utils/helpers.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/templates/lib/utils/helpers.js b/templates/lib/utils/helpers.js index 975ee49..f953f00 100644 --- a/templates/lib/utils/helpers.js +++ b/templates/lib/utils/helpers.js @@ -144,7 +144,20 @@ const mapFormDataBody = async function (action, body) { const putAdditionalParamsInBody = async function (action, body, additionalParameters) { const newBody = body; - const inputMetadataSchema = getInputMetadataSchema(action.metadata.in); + let inputMetadataSchema; + + if (!action.metadata || !action.metadata.in) { + this.logger.warn("No metadata input found"); + return newBody; + } + + try { + inputMetadataSchema = getInputMetadataSchema(action.metadata.in); + } catch (e) { + this.logger.error("Could not fetch input"); + this.logger.error(e); + return newBody + } for (let property in additionalParameters) { if (property in inputMetadataSchema && !(property in body)) {