Skip to content

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

fix: parse JSON fields in certificate policy/profile delete responses

bernie-gbe50388ae904
diff --git a/backend/src/services/certificate-policy/certificate-policy-dal.ts b/backend/src/services/certificate-policy/certificate-policy-dal.ts
index fcc21ec829..f82df2d46e 100644
--- a/backend/src/services/certificate-policy/certificate-policy-dal.ts
+++ b/backend/src/services/certificate-policy/certificate-policy-dal.ts
@@ -120,7 +120,11 @@ export const certificatePolicyDALFactory = (db: TDbClient) => {
.del()
.returning("*")) as Record<string, unknown>[];
- return certificatePolicy;
+ if (!certificatePolicy) {
+ return null;
+ }
+
+ return parseJsonFields(certificatePolicy);
} catch (error) {
throw new DatabaseError({ error, name: "Delete certificate policy" });
}
diff --git a/backend/src/services/certificate-profile/certificate-profile-dal.ts b/backend/src/services/certificate-profile/certificate-profile-dal.ts
index b008ca1d97..5c738c9ca4 100644
--- a/backend/src/services/certificate-profile/certificate-profile-dal.ts
+++ b/backend/src/services/certificate-profile/certificate-profile-dal.ts
@@ -78,13 +78,22 @@ export const certificateProfileDALFactory = (db: TDbClient) => {
}
};
- const deleteById = async (id: string, tx?: Knex): Promise<TCertificateProfile> => {
+ const deleteById = async (id: string, tx?: Knex): Promise<TCertificateProfile | undefined> => {
try {
- const [certificateProfile] = (await (tx || db)(TableName.PkiCertificateProfile)
+ const [certificateProfile] = await (tx || db)(TableName.PkiCertificateProfile)
.where({ id })
.del()
- .returning("*")) as [TCertificateProfile];
- return certificateProfile;
+ .returning("*");
+
+ if (!certificateProfile) return undefined;
+
+ return {
+ ...certificateProfile,
+ externalConfigs: certificateProfile.externalConfigs
+ ? (JSON.parse(certificateProfile.externalConfigs) as Record<string, unknown>)
+ : null,
+ defaults: (certificateProfile.defaults as TCertificateProfileDefaults) ?? null
+ } as TCertificateProfile;
} catch (error) {
throw new DatabaseError({ error, name: "Delete certificate profile" });
}