Skip to content

Commit

Permalink
refactor: prevent encryption of null, undefined, or empty string valu…
Browse files Browse the repository at this point in the history
…es in EncryptedHandler
  • Loading branch information
genu committed Dec 24, 2024
1 parent 29b7d15 commit a7169ef
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/runtime/src/enhancements/node/encrypted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ class EncryptedHandler extends DefaultPrismaProxyHandler {
private async preprocessWritePayload(model: string, action: PrismaWriteActionType, args: any) {
const visitor = new NestedWriteVisitor(this.options.modelMeta, {
field: async (field, _action, data, context) => {
// Don't encrypt null, undefined or empty string values
if (!data) return;

const encAttr = field.attributes?.find((attr) => attr.name === '@encrypted');
if (encAttr && field.type === 'String') {
context.parent[field.name] = await this.encrypt(field, data);
Expand Down

0 comments on commit a7169ef

Please sign in to comment.