Skip to content

Commit 5d6eca4

Browse files
committed
Fix automation retrieval validity check
1 parent 5195236 commit 5d6eca4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/khoj/database/adapters/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,8 @@ def get_automations_metadata(user: KhojUser):
18391839
@staticmethod
18401840
def get_automation(user: KhojUser, automation_id: str) -> Job:
18411841
# Perform validation checks
1842-
# Check if user is allowed to delete this automation id
1843-
if not is_none_or_empty(automation_id) or automation_id.startswith(f"automation_{user.uuid}_"):
1842+
# Check if user is allowed to retrieve this automation id
1843+
if is_none_or_empty(automation_id) or not automation_id.startswith(f"automation_{user.uuid}_"):
18441844
raise ValueError("Invalid automation id")
18451845
# Check if automation with this id exist
18461846
automation: Job = state.scheduler.get_job(job_id=automation_id)
@@ -1852,8 +1852,8 @@ def get_automation(user: KhojUser, automation_id: str) -> Job:
18521852
@staticmethod
18531853
async def aget_automation(user: KhojUser, automation_id: str) -> Job:
18541854
# Perform validation checks
1855-
# Check if user is allowed to delete this automation id
1856-
if not automation_id.startswith(f"automation_{user.uuid}_"):
1855+
# Check if user is allowed to retrieve this automation id
1856+
if is_none_or_empty(automation_id) or not automation_id.startswith(f"automation_{user.uuid}_"):
18571857
raise ValueError("Invalid automation id")
18581858
# Check if automation with this id exist
18591859
automation: Job = await sync_to_async(state.scheduler.get_job)(job_id=automation_id)

0 commit comments

Comments
 (0)