fix: parse JSON fields in certificate policy/profile delete responses#7047
Conversation
The deleteById methods in both certificate-policy-dal and certificate-profile-dal returned raw database rows without parsing JSON fields (subject, sans, keyUsages, externalConfigs, etc.). This caused Fastify's response schema validation to fail with a 500 ResponseValidationError because the Zod schemas expect objects/arrays but received JSON strings. The delete itself succeeded, so the resource was removed, but the API returned a 500 "Something went wrong" to the caller.
|
💬 Discussion in Slack: #pr-review-infisical-7047-fix-parse-json-fields-in-certificate-policy-profile-del Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| backend/src/services/certificate-policy/certificate-policy-dal.ts | Applies the existing parseJsonFields helper to the deleteById return value, matching the pattern already used by create, updateById, and findById; adds a null guard consistent with updateById. |
| backend/src/services/certificate-profile/certificate-profile-dal.ts | Adds manual JSON.parse for externalConfigs and a null guard in deleteById, mirroring the exact pattern already used in create and updateById; changes the return type from TCertificateProfile to `TCertificateProfile |
Reviews (1): Last reviewed commit: "fix: parse JSON fields in certificate po..." | Re-trigger Greptile
Summary
deleteByIdmethods in bothcertificate-policy-dalandcertificate-profile-dalreturned raw database rows without parsing JSON fields (subject,sans,keyUsages,externalConfigs, etc.)ResponseValidationErrorto the caller500 "Something went wrong"-- reported by a customer using Terraform, whereterraform applyafter removing a cert policy from.tffiles would error, requiring a second apply to reconcile stateTest plan