From be4d697dfed7124c8241105fc5ea277bb819fb1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 15:29:01 +0000 Subject: [PATCH] Set hcHealth to 'unknown' when health check is disabled in updateTarget Co-authored-by: oschwartz10612 <4999704+oschwartz10612@users.noreply.github.com> --- server/routers/target/updateTarget.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/routers/target/updateTarget.ts b/server/routers/target/updateTarget.ts index 6e9a8fc9..b9c3eef5 100644 --- a/server/routers/target/updateTarget.ts +++ b/server/routers/target/updateTarget.ts @@ -208,6 +208,12 @@ export async function updateTarget( hcHeaders = JSON.stringify(parsedBody.data.hcHeaders); } + // When health check is disabled, reset hcHealth to "unknown" + // to prevent previously unhealthy targets from being excluded + const hcHealthValue = (parsedBody.data.hcEnabled === false || parsedBody.data.hcEnabled === null) + ? "unknown" + : undefined; + const [updatedHc] = await db .update(targetHealthCheck) .set({ @@ -223,7 +229,8 @@ export async function updateTarget( hcHeaders: hcHeaders, hcFollowRedirects: parsedBody.data.hcFollowRedirects, hcMethod: parsedBody.data.hcMethod, - hcStatus: parsedBody.data.hcStatus + hcStatus: parsedBody.data.hcStatus, + ...(hcHealthValue !== undefined && { hcHealth: hcHealthValue }) }) .where(eq(targetHealthCheck.targetId, targetId)) .returning();