fix(notifications): validate name is not empty
This commit is contained in:
parent
5ec100b3bc
commit
779542e8bd
1 changed files with 9 additions and 1 deletions
|
|
@ -143,6 +143,10 @@ const createDestination = async (name: string, config: NotificationConfig) => {
|
|||
const organizationId = getOrganizationId();
|
||||
const trimmedName = name.trim();
|
||||
|
||||
if (trimmedName.length === 0) {
|
||||
throw new InternalServerError("Name cannot be empty or whitespace-only");
|
||||
}
|
||||
|
||||
const encryptedConfig = await encryptSensitiveFields(config);
|
||||
|
||||
const [created] = await db
|
||||
|
|
@ -178,7 +182,11 @@ const updateDestination = async (
|
|||
};
|
||||
|
||||
if (updates.name !== undefined) {
|
||||
updateData.name = updates.name.trim();
|
||||
const trimmedName = updates.name.trim();
|
||||
if (trimmedName.length === 0) {
|
||||
throw new InternalServerError("Name cannot be empty or whitespace-only");
|
||||
}
|
||||
updateData.name = trimmedName;
|
||||
}
|
||||
|
||||
if (updates.enabled !== undefined) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue