From 3f1ddacce31eb69bab76694f6e966da435bc565c Mon Sep 17 00:00:00 2001 From: Gourav Date: Sun, 16 Jun 2024 12:23:41 +0530 Subject: [PATCH] handled bug cannot create secret in empty file --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 5bfa594..9ddce9d 100644 --- a/main.py +++ b/main.py @@ -131,7 +131,11 @@ async def create_secret(secret: Secret, current_user: dict = Depends(get_current text = f.read() if text: data.extend(json.loads(text)) - secret_id = max(i['id'] for i in data) + 1 + + if data: + secret_id = max(i['id'] for i in data) + 1 + else: + secret_id = 0 secret.id = secret_id secret.user_id = current_user['id'] encryption_key = current_user['encryption_key'].encode()