From db8f43385da9199e8648da60b2e4b5db6de6beea Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Sun, 18 May 2025 00:27:52 +0800 Subject: [PATCH] misc: addressed undefined issue --- .../internal/internal-certificate-authority-service.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts index d165d4d14..af14447a5 100644 --- a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts +++ b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts @@ -1209,6 +1209,10 @@ export const internalCertificateAuthorityServiceFactory = ({ ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(certificateTemplate.caId); } + if (!ca) { + throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); + } + if (!ca?.internalCa?.id) { throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); } @@ -1561,6 +1565,10 @@ export const internalCertificateAuthorityServiceFactory = ({ ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(certificateTemplate.caId); } + if (!ca) { + throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); + } + if (!ca?.internalCa?.id) { throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); }