mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 20:27:12 +00:00
improvement: add name constraint error feedback to update cmek
This commit is contained in:
@@ -86,13 +86,23 @@ export const cmekServiceFactory = ({ kmsService, kmsDAL, permissionService, proj
|
|||||||
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionCmekActions.Edit, ProjectPermissionSub.Cmek);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionCmekActions.Edit, ProjectPermissionSub.Cmek);
|
||||||
|
|
||||||
const cmek = await kmsDAL.updateById(keyId, data);
|
try {
|
||||||
|
const cmek = await kmsDAL.updateById(keyId, data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...cmek,
|
...cmek,
|
||||||
version: key.version,
|
version: key.version,
|
||||||
encryptionAlgorithm: key.encryptionAlgorithm
|
encryptionAlgorithm: key.encryptionAlgorithm
|
||||||
};
|
};
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof DatabaseError && (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: `A KMS key with the name "${data.name!}" already exists for the project with ID "${key.projectId}"`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteCmekById = async (keyId: string, actor: OrgServiceActor) => {
|
const deleteCmekById = async (keyId: string, actor: OrgServiceActor) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user