From 38537b822d7e9c674ee6f5d5934462681c54c7e6 Mon Sep 17 00:00:00 2001 From: AarDG10 Date: Wed, 29 Apr 2026 11:55:52 +0530 Subject: [PATCH] fix(auth): return auth. error in case query fails Previously was running query and throwing trace on failure, we should be raising an Auth. error if failure has occurred during auth. --- frappe/auth.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frappe/auth.py b/frappe/auth.py index 347f6b4e3a..3179bdd41d 100644 --- a/frappe/auth.py +++ b/frappe/auth.py @@ -726,9 +726,13 @@ def validate_api_key_secret(api_key, api_secret, frappe_authorization_source=Non raise frappe.AuthenticationError doctype = frappe_authorization_source or "User" - docname = frappe.db.get_value( - doctype=doctype, filters={"api_key": api_key, "enabled": True}, fieldname=["name"] - ) + try: + docname = frappe.db.get_value( + doctype=doctype, filters={"api_key": api_key, "enabled": True}, fieldname=["name"] + ) + except Exception: + raise frappe.AuthenticationError + if not docname: raise frappe.AuthenticationError form_dict = frappe.local.form_dict