From eb6819a5844b5be535c972c6824c7708498a7781 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 7 Sep 2025 21:30:32 -0400 Subject: check for error when checking if key exists in database --- pypaste/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pypaste/__init__.py b/pypaste/__init__.py index d0991c2..36ca927 100644 --- a/pypaste/__init__.py +++ b/pypaste/__init__.py @@ -111,8 +111,13 @@ class App: except KeyError: return web.HTTPBadRequest(text="provide a key to fetch") - if not await self.database.exists(key): - log_info(f"paste {key} was not found, returning 404") + try: + exists = self.database.exists(key) + except Exception as e: + log_error(f"failed to check if key exists in database: {e}") + return web.HTTPBadRequest() + + if not exists: return web.HTTPNotFound() req = self.bucket.get(key) -- cgit v1.2.3