Skip to content

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

fix(frontend): show error state when certificate export fetch fails

Devin AI2bda2fc7c837
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx
index 8d29c42564..b2e03c39ec 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaCertModal.tsx
@@ -17,7 +17,7 @@ type Props = {
};
export const CaCertModal = ({ popUp, handlePopUpToggle }: Props) => {
- const { data } = useGetCaCert((popUp?.caCert?.data as { caId: string })?.caId || "");
+ const { data, isError } = useGetCaCert((popUp?.caCert?.data as { caId: string })?.caId || "");
return (
<Dialog
open={popUp?.caCert?.isOpen}
@@ -30,13 +30,17 @@ export const CaCertModal = ({ popUp, handlePopUpToggle }: Props) => {
<DialogTitle>CA Certificate</DialogTitle>
<DialogDescription>Copy or download the CA certificate and its chain.</DialogDescription>
</DialogHeader>
- {data ? (
+ {data && (
<CertificateContent
serialNumber={data.serialNumber}
certificate={data.certificate}
certificateChain={data.certificateChain}
/>
- ) : (
+ )}
+ {!data && isError && (
+ <p className="py-8 text-center text-sm text-danger">Failed to load CA certificate.</p>
+ )}
+ {!data && !isError && (
<div className="py-8">
<PageLoader />
</div>
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx
index 142ef7a075..da54b15d57 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateCertModal.tsx
@@ -54,7 +54,7 @@ export const CertificateCertModal = ({ popUp, handlePopUpToggle, applicationId }
// With metadata-based RBAC conditions the generic check may be overly
// optimistic, so we always fetch the cert body as a fallback.
const { data: bundleData } = useGetCertBundle(canReadPrivateKey ? serialNumber : "");
- const { data: bodyData } = useGetCertBody(serialNumber);
+ const { data: bodyData, isError } = useGetCertBody(serialNumber);
// Prefer bundle data (cert + key) when available, otherwise fall back to
// body data (cert only). This ensures the certificate is always shown even
@@ -82,14 +82,18 @@ export const CertificateCertModal = ({ popUp, handlePopUpToggle, applicationId }
Copy or download the certificate and its key material.
</DialogDescription>
</DialogHeader>
- {data ? (
+ {data && (
<CertificateContent
serialNumber={data.serialNumber}
certificate={data.certificate}
certificateChain={data.certificateChain}
privateKey={data.privateKey || undefined}
/>
- ) : (
+ )}
+ {!data && isError && (
+ <p className="py-8 text-center text-sm text-danger">Failed to load certificate.</p>
+ )}
+ {!data && !isError && (
<div className="py-8">
<PageLoader />
</div>