From ce56047dd63d6cf76d49f7487dda680d315debbf Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Wed, 15 Jan 2025 12:25:21 +0530 Subject: [PATCH] fix: do not migrate old passwords if decryption fails (cherry picked from commit 7e8d515993ccd33b9c791abd6a12c6d6f47cb644) --- .../migrate_e_invoice_settings_to_gst_settings.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/india_compliance/patches/post_install/migrate_e_invoice_settings_to_gst_settings.py b/india_compliance/patches/post_install/migrate_e_invoice_settings_to_gst_settings.py index 244fe7f3d8..0b4223ad34 100644 --- a/india_compliance/patches/post_install/migrate_e_invoice_settings_to_gst_settings.py +++ b/india_compliance/patches/post_install/migrate_e_invoice_settings_to_gst_settings.py @@ -1,6 +1,7 @@ import click import frappe +from frappe import _ from frappe.utils import sbool from frappe.utils.password import decrypt @@ -63,7 +64,18 @@ def get_credentials_from_e_invoice_user(): ) for credential in old_credentials: - credential.password = credential.password and decrypt(credential.password) + try: + password = credential.password and decrypt(credential.password) + except Exception as e: + password = None + frappe.log_error( + title=_( + "Failed to decrypt password for E Invoice User {0} - {1}" + ).format(credential.company, credential.gstin), + message=e, + ) + + credential.password = password credential.service = "e-Waybill / e-Invoice" return old_credentials