From 8986d67089816ad56ba5d64c08283adf1dcd35d1 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:04:10 +0100 Subject: [PATCH] chore: typebox debug --- src/workflow-entry.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/workflow-entry.ts b/src/workflow-entry.ts index fc5e774..62ac050 100644 --- a/src/workflow-entry.ts +++ b/src/workflow-entry.ts @@ -11,9 +11,22 @@ import { bubbleUpErrorComment, sanitizeMetadata } from "./utils/errors"; */ export async function run() { const payload = github.context.payload.inputs; + let env, settings; + try { + env = Value.Decode(envValidator.schema, payload.env); + } catch (err) { + console.log("Error decoding env: ", err); + } + + try { + settings = Value.Decode(pluginSettingsSchema, Value.Default(pluginSettingsSchema, JSON.parse(payload.settings))); + } catch (err) { + console.log("Error decoding settings: ", err); + } - const env = Value.Decode(envValidator.schema, payload.env); - const settings = Value.Decode(pluginSettingsSchema, Value.Default(pluginSettingsSchema, JSON.parse(payload.settings))); + if (!(settings && env)) { + throw new Error("Invalid settings or env provided"); + } if (!pluginSettingsValidator.test(settings)) { throw new Error("Invalid settings provided");