Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

remove dead code

Thiago Araujo da Silva446988652805
diff --git a/backend/src/db/migrations/20260714120000_add-alerts.ts b/backend/src/db/migrations/20260714120000_add-alerts.ts
index 983a3418bc..0690b0cc12 100644
--- a/backend/src/db/migrations/20260714120000_add-alerts.ts
+++ b/backend/src/db/migrations/20260714120000_add-alerts.ts
@@ -79,8 +79,9 @@ export async function up(knex: Knex): Promise<void> {
await createOnUpdateTrigger(knex, TableName.AlertChannelRecipient);
}
- // Many-to-many between alerts and channels. The count of rows for a channel powers the "used by N
- // alerts" column in the UI.
+ // Many-to-many between alerts and channels. Channels are currently only ever created inline by their
+ // owning alert, so in practice every channel has exactly one membership row; the join table exists so
+ // a channel can later be shared across alerts without a schema change.
if (!(await knex.schema.hasTable(TableName.AlertChannelMembership))) {
await knex.schema.createTable(TableName.AlertChannelMembership, (t) => {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
diff --git a/backend/src/server/routes/v1/alert-router.ts b/backend/src/server/routes/v1/alert-router.ts
index d61f9e81a0..171d9b848d 100644
--- a/backend/src/server/routes/v1/alert-router.ts
+++ b/backend/src/server/routes/v1/alert-router.ts
@@ -49,7 +49,6 @@ const AlertResponseSchema = z.object({
id: z.string().uuid(),
name: z.string(),
channelType: z.string(),
- directed: z.boolean(),
enabled: z.boolean(),
config: z.record(z.unknown()),
recipients: z.array(z.object({ principalType: z.string(), principalId: z.string() }))
diff --git a/backend/src/services/alert/alert-channel-membership-dal.ts b/backend/src/services/alert/alert-channel-membership-dal.ts
index ceab6005c7..c0966a04ae 100644
--- a/backend/src/services/alert/alert-channel-membership-dal.ts
+++ b/backend/src/services/alert/alert-channel-membership-dal.ts
@@ -1,28 +1,7 @@
-import { Knex } from "knex";
-
import { TDbClient } from "@app/db";
import { TableName } from "@app/db/schemas";
-import { DatabaseError } from "@app/lib/errors";
import { ormify } from "@app/lib/knex";
export type TAlertChannelMembershipDALFactory = ReturnType<typeof alertChannelMembershipDALFactory>;
-export const alertChannelMembershipDALFactory = (db: TDbClient) => {
- const alertChannelMembershipOrm = ormify(db, TableName.AlertChannelMembership);
-
- const countByChannelId = async (channelId: string, tx?: Knex): Promise<number> => {
- try {
- const [row] = await (tx || db.replicaNode())(TableName.AlertChannelMembership)
- .where(`${TableName.AlertChannelMembership}.channelId`, channelId)
- .count({ count: "*" });
- return Number((row as { count?: string | number })?.count ?? 0);
- } catch (error) {
- throw new DatabaseError({ error, name: "CountByChannelId" });
- }
- };
-
- return {
- ...alertChannelMembershipOrm,
- countByChannelId
- };
-};
+export const alertChannelMembershipDALFactory = (db: TDbClient) => ormify(db, TableName.AlertChannelMembership);
diff --git a/backend/src/services/alert/alert-channel-recipient-dal.ts b/backend/src/services/alert/alert-channel-recipient-dal.ts
index 503b061cac..6101b18722 100644
--- a/backend/src/services/alert/alert-channel-recipient-dal.ts
+++ b/backend/src/services/alert/alert-channel-recipient-dal.ts
@@ -12,18 +12,6 @@ export type TAlertChannelRecipientDALFactory = ReturnType<typeof alertChannelRec
export const alertChannelRecipientDALFactory = (db: TDbClient) => {
const alertChannelRecipientOrm = ormify(db, TableName.AlertChannelRecipient);
- const findByChannelId = async (channelId: string, tx?: Knex): Promise<TAlertChannelRecipients[]> => {
- try {
- const recipients = await (tx || db.replicaNode())(TableName.AlertChannelRecipient)
- .where(`${TableName.AlertChannelRecipient}.channelId`, channelId)
- .select(selectAllTableCols(TableName.AlertChannelRecipient));
-
- return recipients as TAlertChannelRecipients[];
- } catch (error) {
- throw new DatabaseError({ error, name: "FindByChannelId" });
- }
- };
-
const findByChannelIds = async (channelIds: string[], tx?: Knex): Promise<TAlertChannelRecipients[]> => {
try {
if (!channelIds.length) return [];
@@ -70,7 +58,6 @@ export const alertChannelRecipientDALFactory = (db: TDbClient) => {
return {
...alertChannelRecipientOrm,
- findByChannelId,
findByChannelIds,
deleteByChannelId,
deleteUsersRecipientsByScope
diff --git a/backend/src/services/alert/alert-channel-service-types.ts b/backend/src/services/alert/alert-channel-service-types.ts
index 5af0e01111..c6afd36e1c 100644
--- a/backend/src/services/alert/alert-channel-service-types.ts
+++ b/backend/src/services/alert/alert-channel-service-types.ts
@@ -10,7 +10,6 @@ export type TAlertChannelEmbedded = {
id: string;
name: string;
channelType: string;
- directed: boolean;
enabled: boolean;
config: Record<string, unknown>;
recipients: { principalType: string; principalId: string }[];
diff --git a/backend/src/services/alert/alert-channel-service.test.ts b/backend/src/services/alert/alert-channel-service.test.ts
index bcf6b9c33b..b712ea11f7 100644
--- a/backend/src/services/alert/alert-channel-service.test.ts
+++ b/backend/src/services/alert/alert-channel-service.test.ts
@@ -62,7 +62,6 @@ const buildService = (opts?: { seed?: TRow[] }) => {
data.forEach((r) => recipients.set(r.channelId, [...(recipients.get(r.channelId) ?? []), r]));
return data;
},
- findByChannelId: async (channelId: string) => recipients.get(channelId) ?? [],
findByChannelIds: async (ids: string[]) => ids.flatMap((id) => recipients.get(id) ?? []),
deleteByChannelId: async (channelId: string) => {
recipients.delete(channelId);
@@ -167,7 +166,7 @@ describe("alert channel service", () => {
tx
);
const [detail] = await service.getDetailsForChannels([channel], { decryptor: decryptor as never });
- expect(detail.directed).toBe(true);
+ expect(detail.channelType).toBe(AlertChannelType.EMAIL);
expect(detail.recipients).toEqual([{ principalType: "user", principalId: "user-1" }]);
expect(recipients.get(channel.id)).toHaveLength(1);
});
diff --git a/backend/src/services/alert/alert-channel-service.ts b/backend/src/services/alert/alert-channel-service.ts
index 72c3e8b8d6..4734daf64f 100644
--- a/backend/src/services/alert/alert-channel-service.ts
+++ b/backend/src/services/alert/alert-channel-service.ts
@@ -30,8 +30,9 @@ export type TAlertChannelServiceFactoryDep = {
export type TAlertChannelServiceFactory = ReturnType<typeof alertChannelServiceFactory>;
-// Everything the transaction-aware primitives need to write a channel inline, without the standalone
-// endpoint's org/project Settings permission check or reusable-name-uniqueness check.
+// Everything the transaction-aware primitives need to write a channel inline. Channels are only ever
+// created through their owning alert, so authorization is the alert's (the caller has already run the
+// provider's assertPermission) and channel names are not required to be unique.
export type TCreateChannelInTxInput = {
name: string;
channelType: AlertChannelType | string;
@@ -293,13 +294,11 @@ export const alertChannelServiceFactory = ({
});
return channels.map((channel) => {
- const definition = ALERT_CHANNEL_REGISTRY[channel.channelType as AlertChannelType];
const config = decryptChannelConfig<Record<string, unknown>>(channel.encryptedConfig, cipher.decryptor);
return {
id: channel.id,
name: channel.name,
channelType: channel.channelType,
- directed: Boolean(definition?.directed),
enabled: channel.enabled,
config: $redactConfig(channel.channelType, config),
recipients: recipientsByChannel.get(channel.id) ?? []
diff --git a/backend/src/services/alert/alert-service.test.ts b/backend/src/services/alert/alert-service.test.ts
index a6f64b3244..493fdfc660 100644
--- a/backend/src/services/alert/alert-service.test.ts
+++ b/backend/src/services/alert/alert-service.test.ts
@@ -20,9 +20,6 @@ type TChannelRow = {
updatedAt: Date;
};
-// Email is the only directed channel type; mirror the registry so response assembly reports `directed` correctly.
-const isDirected = (channelType: AlertChannelType | string) => channelType === AlertChannelType.EMAIL;
-
const buildService = (opts?: {
assertPermission?: (input: TAlertPermissionInput) => Promise<void>;
resourceScopeThrows?: boolean;
@@ -179,7 +176,6 @@ const buildService = (opts?: {
id: c.id,
name: c.name,
channelType: c.channelType,
- directed: isDirected(c.channelType),
enabled: c.enabled,
config: {},
recipients: c.recipients ?? []
@@ -234,8 +230,9 @@ describe("alert service", () => {
expect(alert.id).toBe("alert-1");
expect(alert.orgId).toBe("org-1");
expect(alert.channels).toHaveLength(2);
- expect(alert.channels.find((c) => c.channelType === AlertChannelType.EMAIL)?.directed).toBe(true);
- expect(alert.channels.find((c) => c.channelType === AlertChannelType.WEBHOOK)?.directed).toBe(false);
+ expect(alert.channels.map((c) => c.channelType).sort()).toEqual(
+ [AlertChannelType.EMAIL, AlertChannelType.WEBHOOK].sort()
+ );
expect(memberships.get("alert-1")).toHaveLength(2);
expect(permissionCalls[0].action).toBe("create");
});
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts
index 8671094f8a..12bad96fe0 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts
@@ -1,9 +1,10 @@
import { getConfig } from "@app/lib/config/env";
import { delay } from "@app/lib/delay";
import { logger } from "@app/lib/logger";
+import { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";
import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service";
-import { PKI_ALERT_RETRY_CONFIG, RETRYABLE_NETWORK_ERRORS } from "./pki-alert-v2-constants";
+import { PKI_ALERT_RETRY_CONFIG } from "./pki-alert-v2-constants";
import {
getRevocationReasonLabel,
PkiAlertEventType,
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts
index 064267b5c9..ba59106498 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts
@@ -4,8 +4,9 @@ import { getConfig } from "@app/lib/config/env";
import { request } from "@app/lib/config/request";
import { delay } from "@app/lib/delay";
import { logger } from "@app/lib/logger";
+import { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";
-import { PKI_ALERT_RETRY_CONFIG, RETRYABLE_NETWORK_ERRORS } from "./pki-alert-v2-constants";
+import { PKI_ALERT_RETRY_CONFIG } from "./pki-alert-v2-constants";
import {
getRevocationReasonLabel,
pagerDutyIntegrationKeyRegex,
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts
index 88f92bffe6..a2ccc4d141 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts
@@ -5,10 +5,11 @@ import { request } from "@app/lib/config/request";
import { delay } from "@app/lib/delay";
import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
+import { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";
import { SLACK_WEBHOOK_TIMEOUT, TSlackBlock, TSlackPayload } from "@app/lib/slack/slack-webhook";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator/validate-url";
-import { PKI_ALERT_RETRY_CONFIG, RETRYABLE_NETWORK_ERRORS } from "./pki-alert-v2-constants";
+import { PKI_ALERT_RETRY_CONFIG } from "./pki-alert-v2-constants";
import {
getRevocationReasonLabel,
PkiAlertEventType,
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts
index 6c082bc6b5..84df4753ed 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts
@@ -6,9 +6,10 @@ import { getConfig } from "@app/lib/config/env";
import { request } from "@app/lib/config/request";
import { delay } from "@app/lib/delay";
import { logger } from "@app/lib/logger";
+import { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator/validate-url";
-import { PKI_ALERT_RETRY_CONFIG, RETRYABLE_NETWORK_ERRORS } from "./pki-alert-v2-constants";
+import { PKI_ALERT_RETRY_CONFIG } from "./pki-alert-v2-constants";
import {
getRevocationReasonLabel,
PkiWebhookEventType,
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-constants.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-constants.ts
index 16c44fd3a5..c1ac4185e4 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-constants.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-constants.ts
@@ -1,3 +1 @@
-export { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";
-
export const PKI_ALERT_RETRY_CONFIG = { maxRetries: 3, delayMs: 3000 };
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx
index 1aafa34976..1fa1900e7b 100644
--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx
+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx
@@ -25,7 +25,7 @@ import {
useDeleteAlert,
useListAlerts
} from "@app/hooks/api/alerts";
-import { AddAlertModal } from "@app/views/AlertsPage/components/AddAlertModal";
+import { AddAlertModal } from "@app/views/Alerts";
type Props = {
identityId: string;
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertDetail.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertDetail.tsx
index 8a83e1a21c..94085b1d32 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertDetail.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertDetail.tsx
@@ -26,7 +26,7 @@ import {
useDeleteAlert,
useListAlerts
} from "@app/hooks/api/alerts";
-import { AddAlertModal } from "@app/views/AlertsPage/components/AddAlertModal";
+import { AddAlertModal } from "@app/views/Alerts";
type Props = {
identityId: string;
diff --git a/frontend/src/views/AlertsPage/components/AddAlertModal.tsx b/frontend/src/views/Alerts/AddAlertModal.tsx
similarity index 100%
rename from frontend/src/views/AlertsPage/components/AddAlertModal.tsx
rename to frontend/src/views/Alerts/AddAlertModal.tsx
diff --git a/frontend/src/views/AlertsPage/components/AlertForm.tsx b/frontend/src/views/Alerts/AlertForm.tsx
similarity index 100%
rename from frontend/src/views/AlertsPage/components/AlertForm.tsx
rename to frontend/src/views/Alerts/AlertForm.tsx
diff --git a/frontend/src/views/AlertsPage/components/ChannelCard.tsx b/frontend/src/views/Alerts/ChannelCard.tsx
similarity index 100%
rename from frontend/src/views/AlertsPage/components/ChannelCard.tsx
rename to frontend/src/views/Alerts/ChannelCard.tsx
diff --git a/frontend/src/views/AlertsPage/components/ChannelRecipientsField.tsx b/frontend/src/views/Alerts/ChannelRecipientsField.tsx
similarity index 100%
rename from frontend/src/views/AlertsPage/components/ChannelRecipientsField.tsx
rename to frontend/src/views/Alerts/ChannelRecipientsField.tsx
diff --git a/frontend/src/views/AlertsPage/components/ChannelsField.tsx b/frontend/src/views/Alerts/ChannelsField.tsx
similarity index 100%
rename from frontend/src/views/AlertsPage/components/ChannelsField.tsx
rename to frontend/src/views/Alerts/ChannelsField.tsx
diff --git a/frontend/src/views/AlertsPage/components/channelIcons.ts b/frontend/src/views/Alerts/channelIcons.ts
similarity index 100%
rename from frontend/src/views/AlertsPage/components/channelIcons.ts
rename to frontend/src/views/Alerts/channelIcons.ts
diff --git a/frontend/src/views/Alerts/index.ts b/frontend/src/views/Alerts/index.ts
new file mode 100644
index 0000000000..baa7a1e924
--- /dev/null
+++ b/frontend/src/views/Alerts/index.ts
@@ -0,0 +1 @@
+export { AddAlertModal } from "./AddAlertModal";