Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
G2P-2231: Registry Encryption: Fixed error upon update
Browse files Browse the repository at this point in the history
Signed-off-by: Lalith Kota <[email protected]>
  • Loading branch information
lalithkota committed Apr 23, 2024
1 parent d72ab2b commit 76fd909
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions g2p_registry_encryption/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def gather_fields_to_be_enc_from_dict(
):
to_be_enc = {}
for each in prov.get_registry_fields_set_to_enc():
if fields_dict.get(each, None):
if fields_dict and fields_dict.get(each, None):
to_be_enc[each] = fields_dict[each]
if replace:
fields_dict[each] = prov.registry_enc_field_placeholder
Expand Down Expand Up @@ -63,7 +63,9 @@ def write(self, vals):
rec_values_list["is_encrypted"] = True
vals = rec_values_list
else:
vals = json.loads(prov.decrypt_data(encrypted_val).decode()).update(vals)
decrypted_vals = json.loads(prov.decrypt_data(encrypted_val or b"{}").decode())
decrypted_vals.update(vals)
vals = decrypted_vals
to_be_encrypted = self.gather_fields_to_be_enc_from_dict(vals, prov)

vals["encrypted_val"] = prov.encrypt_data(json.dumps(to_be_encrypted).encode())
Expand Down

0 comments on commit 76fd909

Please sign in to comment.