From 678644c7fb0a6c8ad5ec46f171bd71078eeaecd1 Mon Sep 17 00:00:00 2001 From: Owen Date: Thu, 30 Oct 2025 21:09:20 -0700 Subject: [PATCH] Fix empty blueprint --- .../blueprints/applyNewtDockerBlueprint.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/server/lib/blueprints/applyNewtDockerBlueprint.ts b/server/lib/blueprints/applyNewtDockerBlueprint.ts index ab185caa..5a80bb66 100644 --- a/server/lib/blueprints/applyNewtDockerBlueprint.ts +++ b/server/lib/blueprints/applyNewtDockerBlueprint.ts @@ -29,6 +29,23 @@ export async function applyNewtDockerBlueprint( logger.debug(`Received Docker blueprint: ${JSON.stringify(blueprint)}`); + // make sure this is not an empty object + if (isEmptyObject(blueprint)) { + throw new Error("No valid blueprint data found in container labels"); + } + + if (isEmptyObject(blueprint["proxy-resources"])) { + throw new Error( + "No proxy-resources found in blueprint data from container labels" + ); + } + + if (isEmptyObject(blueprint["client-resources"])) { + throw new Error( + "No client-resources found in blueprint data from container labels" + ); + } + // Update the blueprint in the database await applyBlueprint({ orgId: site.orgId, @@ -42,7 +59,7 @@ export async function applyNewtDockerBlueprint( type: "newt/blueprint/results", data: { success: false, - message: `Failed to update database from config: ${error}` + message: `Failed to apply blueprint from config: ${error}` } }); return; @@ -56,3 +73,10 @@ export async function applyNewtDockerBlueprint( } }); } + +function isEmptyObject(obj: any) { + if (obj === null || obj === undefined) { + return true; + } + return Object.keys(obj).length === 0 && obj.constructor === Object; +} \ No newline at end of file