From ed0bf5d6aed59ea549948ec0b7d3a10c1e27f256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Didderen?= Date: Tue, 27 Oct 2026 22:54:07 +0100 Subject: [PATCH] [FIX] account_ebics - Report passphrase mismatch when checking keys The keyring was built outside the try block, and fintech raises the passphrase error from the EbicsKeyRing constructor: a wrong passphrase showed a raw ValueError traceback instead of "Passphrase mismatch.". When another keyring instance on the same file is still open in the worker, fintech raises RuntimeError instead, which is now caught too. --- account_ebics/models/ebics_userid.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/account_ebics/models/ebics_userid.py b/account_ebics/models/ebics_userid.py index 821329a..304d013 100644 --- a/account_ebics/models/ebics_userid.py +++ b/account_ebics/models/ebics_userid.py @@ -281,15 +281,17 @@ class EbicsUserID(models.Model): "keys": self.ebics_keys_fn, "passphrase": self.ebics_passphrase, } - keyring = EbicsKeyRing(**keyring_params) try: + keyring = EbicsKeyRing(**keyring_params) # fintech <= 7.4.3 does not have a call to check if a # passphrase matches with the value stored in the keyfile. # We get around this limitation as follows: # Get user keys to check for valid passphrases - # It will raise a ValueError on invalid passphrases - keyring["#USER"] - except ValueError as err: # noqa: F841 + # It will raise a ValueError on invalid passphrases, + # or a RuntimeError when the keyring is already open + # in this process with another passphrase. + keyring["#USER"] # pylint: disable=pointless-statement + except (ValueError, RuntimeError) as err: # noqa: F841 raise UserError(self.env._("Passphrase mismatch.")) # noqa: B904 elif self.state != "draft": self.ebics_passphrase = False