From 26e96839e4ad707904b25093e97f8085d3cb7de9 Mon Sep 17 00:00:00 2001
From: Philip Sargent <philip.sargent@gmail.com>
Date: Fri, 14 Jul 2023 11:22:48 +0200
Subject: [PATCH] stop crash onloading wallet with blank caveid

---
 core/views/wallets_edit.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/views/wallets_edit.py b/core/views/wallets_edit.py
index 5bf0032..2387123 100644
--- a/core/views/wallets_edit.py
+++ b/core/views/wallets_edit.py
@@ -237,8 +237,11 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
                     i = i.replace("/", "-")
                     caveobject = getCave(i)  # only the last one gets recorded.. ouch.
             else:
-                caveid = caveid
-                caveobject = getCave(caveid)
+                caveid = caveid # ?urk? why?
+                try:
+                    caveobject = getCave(caveid) # may fail if garbage value ,e.g. space, in wallet data
+                except MultipleObjectsReturned: 
+                    caveobject = None
             print(f'getCave for id "{waldata["cave"]}" {caveobject}')
             # if not caveobject.url == waldata["description url"]:
             # complaints.append(f'The URL of cave description \"{waldata["description url"]}\" does not match the one on record for this cave which is: "{caveobject.url}". If the wallet is not for a cave, put a useful URL here.')