Fix errors

This commit is contained in:
Owen
2026-04-21 12:17:24 -07:00
parent 7da3719a00
commit e765f661a7
2 changed files with 24 additions and 4 deletions

View File

@@ -191,11 +191,19 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
}) })
.where(eq(targetHealthCheck.targetId, targetCheck.targetId)); .where(eq(targetHealthCheck.targetId, targetCheck.targetId));
const orgId = targetCheck.orgId || targetCheck.resourceOrgId; // for backwards compatibility, check both orgId fields because the target health checks dont have the orgId
if (!orgId) {
logger.warn(
`No org ID found for target ${targetId}, skipping status history logging`
);
continue;
}
// Log the state change to status history // Log the state change to status history
await db.insert(statusHistory).values({ await db.insert(statusHistory).values({
entityType: "healthCheck", entityType: "healthCheck",
entityId: targetCheck.targetHealthCheckId, entityId: targetCheck.targetHealthCheckId,
orgId: targetCheck.orgId || targetCheck.resourceOrgId, orgId: orgId,
status: healthStatus.status, status: healthStatus.status,
timestamp: Math.floor(Date.now() / 1000) timestamp: Math.floor(Date.now() / 1000)
}); });
@@ -235,7 +243,7 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
await db.insert(statusHistory).values({ await db.insert(statusHistory).values({
entityType: "resource", entityType: "resource",
entityId: targetCheck.resourceId, entityId: targetCheck.resourceId,
orgId: targetCheck.orgId || targetCheck.resourceOrgId, orgId: orgId,
status: status, status: status,
timestamp: Math.floor(Date.now() / 1000) timestamp: Math.floor(Date.now() / 1000)
}); });
@@ -244,13 +252,13 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
// because we are checking above if there was a change we can fire the alert here because it changed // because we are checking above if there was a change we can fire the alert here because it changed
if (healthStatus.status === "unhealthy") { if (healthStatus.status === "unhealthy") {
await fireHealthCheckHealthyAlert( await fireHealthCheckHealthyAlert(
targetCheck.orgId || targetCheck.resourceOrgId, // for backwards compatibility, check both orgId fields because the target health checks dont have the orgId orgId,
targetCheck.targetHealthCheckId, targetCheck.targetHealthCheckId,
targetCheck.name targetCheck.name
); );
} else if (healthStatus.status === "healthy") { } else if (healthStatus.status === "healthy") {
await fireHealthCheckNotHealthyAlert( await fireHealthCheckNotHealthyAlert(
targetCheck.orgId || targetCheck.resourceOrgId, // for backwards compatibility, check both orgId fields because the target health checks dont have the orgId orgId,
targetCheck.targetHealthCheckId, targetCheck.targetHealthCheckId,
targetCheck.name targetCheck.name
); );

View File

@@ -346,10 +346,16 @@ export default function AlertRuleGraphEditor({
useWatch({ control: form.control, name: "enabled" }) ?? true; useWatch({ control: form.control, name: "enabled" }) ?? true;
const wSourceType = const wSourceType =
useWatch({ control: form.control, name: "sourceType" }) ?? "site"; useWatch({ control: form.control, name: "sourceType" }) ?? "site";
const wAllSites =
useWatch({ control: form.control, name: "allSites" }) ?? true;
const wSiteIds = const wSiteIds =
useWatch({ control: form.control, name: "siteIds" }) ?? []; useWatch({ control: form.control, name: "siteIds" }) ?? [];
const wAllHealthChecks =
useWatch({ control: form.control, name: "allHealthChecks" }) ?? true;
const wHealthCheckIds = const wHealthCheckIds =
useWatch({ control: form.control, name: "healthCheckIds" }) ?? []; useWatch({ control: form.control, name: "healthCheckIds" }) ?? [];
const wAllResources =
useWatch({ control: form.control, name: "allResources" }) ?? true;
const wResourceIds = const wResourceIds =
useWatch({ control: form.control, name: "resourceIds" }) ?? []; useWatch({ control: form.control, name: "resourceIds" }) ?? [];
const wTrigger = const wTrigger =
@@ -363,8 +369,11 @@ export default function AlertRuleGraphEditor({
name: wName, name: wName,
enabled: wEnabled, enabled: wEnabled,
sourceType: wSourceType, sourceType: wSourceType,
allSites: wAllSites,
siteIds: wSiteIds, siteIds: wSiteIds,
allHealthChecks: wAllHealthChecks,
healthCheckIds: wHealthCheckIds, healthCheckIds: wHealthCheckIds,
allResources: wAllResources,
resourceIds: wResourceIds, resourceIds: wResourceIds,
trigger: wTrigger, trigger: wTrigger,
actions: wActions actions: wActions
@@ -373,8 +382,11 @@ export default function AlertRuleGraphEditor({
wName, wName,
wEnabled, wEnabled,
wSourceType, wSourceType,
wAllSites,
wSiteIds, wSiteIds,
wAllHealthChecks,
wHealthCheckIds, wHealthCheckIds,
wAllResources,
wResourceIds, wResourceIds,
wTrigger, wTrigger,
wActions wActions