Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
remove unued code
Thiago Araujo da Silvac2ac3db50ae2
diff --git a/backend/src/services/alarm/alarm-provider-registry.ts b/backend/src/services/alarm/alarm-provider-registry.tsindex a7d529849d..45d482c1c0 100644--- a/backend/src/services/alarm/alarm-provider-registry.ts+++ b/backend/src/services/alarm/alarm-provider-registry.ts@@ -16,7 +16,5 @@ export const alarmProviderRegistryFactory = () => {const resourceTypes = (): string[] => [...providers.keys()];- const list = (): IResourceAlarmProvider[] => [...providers.values()];-- return { register, get, resourceTypes, list };+ return { register, get, resourceTypes };};diff --git a/backend/src/services/alarm/alarm-service.test.ts b/backend/src/services/alarm/alarm-service.test.tsindex 87a38ff6a0..3c877ddc59 100644--- a/backend/src/services/alarm/alarm-service.test.ts+++ b/backend/src/services/alarm/alarm-service.test.ts@@ -124,7 +124,7 @@ const buildService = (opts?: {}} as unknown as TAlarmServiceFactoryDep);- return { service, permissionCalls, alarms, channels, findFilters };+ return { service, permissionCalls, alarms, channels, recipients, findFilters };};const actor = {@@ -399,6 +399,35 @@ describe("alarm service", () => {expect(updated.channels[0].config).toEqual({ url: "https://new.example.com/hook", hasSigningSecret: false });});+ test("allows a channel-only update of an email alarm using its existing recipients", async () => {+ const { service, recipients } = seedAlarmWithChannel(AlarmChannelType.EMAIL, {});+ recipients.set("alarm-1", [{ principalType: AlarmPrincipalType.USER, principalId: "user-1" }]);++ // No recipients in the update, but the alarm already has one; the directed-channel requirement+ // must be satisfied by the existing recipients rather than rejecting the edit.+ const updated = await service.updateAlarm({+ alarmId: "alarm-1",+ name: "renamed",+ channels: [{ id: "c0", channelType: AlarmChannelType.EMAIL, config: {} }],+ ...actor+ });++ expect(updated.name).toBe("renamed");+ expect(updated.recipients).toEqual([{ principalType: "user", principalId: "user-1" }]);+ });++ test("still rejects an email channel when the alarm has no recipients", async () => {+ const { service } = seedAlarmWithChannel(AlarmChannelType.EMAIL, {});++ await expect(+ service.updateAlarm({+ alarmId: "alarm-1",+ channels: [{ id: "c0", channelType: AlarmChannelType.EMAIL, config: {} }],+ ...actor+ })+ ).rejects.toThrow("At least one recipient is required");+ });+test("deletes an alarm after checking Delete permission", async () => {const { service, permissionCalls } = buildService();await service.createAlarm(validCreate);diff --git a/backend/src/services/alarm/alarm-service.ts b/backend/src/services/alarm/alarm-service.tsindex ffd9917824..db89e1b9e4 100644--- a/backend/src/services/alarm/alarm-service.ts+++ b/backend/src/services/alarm/alarm-service.ts@@ -435,10 +435,17 @@ export const alarmServiceFactory = ({});}+ // When channels are updated without recipients, the alarm keeps its existing recipients (the+ // transaction below only touches recipients when dto.recipients is provided). Validate the+ // directed-channel requirement against those existing recipients, not an empty list, so a+ // channel-only edit of an email alarm isn't wrongly rejected.+ const effectiveRecipients =+ dto.recipients ?? (resolvedChannels ? await alarmRecipientDAL.findByAlarmId(alarm.id) : undefined);+$validate(provider, {condition: dto.condition,channels: resolvedChannels,- recipients: dto.recipients ?? (resolvedChannels ? [] : undefined)+ recipients: effectiveRecipients});if (dto.recipients) await $validateRecipients(alarm.orgId, alarm.projectId, dto.recipients);diff --git a/backend/src/services/alarm/channels/alarm-channel-registry.ts b/backend/src/services/alarm/channels/alarm-channel-registry.tsindex 203ac22e12..140dc55150 100644--- a/backend/src/services/alarm/channels/alarm-channel-registry.ts+++ b/backend/src/services/alarm/channels/alarm-channel-registry.ts@@ -41,6 +41,3 @@ export const ALARM_CHANNEL_REGISTRY: Record<AlarmChannelType, TAlarmChannelDefinsend: sendPagerDutyNotification}};--export const getAlarmChannelDefinition = (type: AlarmChannelType): TAlarmChannelDefinition =>- ALARM_CHANNEL_REGISTRY[type];