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()