From 1a9829b93bbf7f8924e125581472392bb72e2b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Wed, 10 May 2023 16:00:07 +0200 Subject: [PATCH] handle missing KeePass entry --- src/ldaptool/search/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ldaptool/search/config.py b/src/ldaptool/search/config.py index 438d980..730b70b 100644 --- a/src/ldaptool/search/config.py +++ b/src/ldaptool/search/config.py @@ -148,6 +148,8 @@ class Keepass(PasswordManager): password = getpass.getpass(f"KeePass password for database {self.database}: ") kp = pykeepass.PyKeePass(self.database, password=password) entry = kp.find_entries(username=password_name, first=True) + if not entry: + raise SystemExit(f"no KeePass entry for {password_name!r} found") return entry.password # type: ignore