mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Log invalid automation ids for investigation and clean-up
This commit is contained in:
@@ -1957,7 +1957,7 @@ class AutomationAdapters:
|
||||
# Perform validation checks
|
||||
# Check if user is allowed to delete this automation id
|
||||
if not automation.id.startswith(f"automation_{user.uuid}_"):
|
||||
raise ValueError("Invalid automation id")
|
||||
raise ValueError(f"Invalid automation id: {automation.id}")
|
||||
|
||||
automation_metadata = json.loads(automation.name)
|
||||
crontime = automation_metadata["crontime"]
|
||||
@@ -1978,7 +1978,7 @@ class AutomationAdapters:
|
||||
# Perform validation checks
|
||||
# Check if user is allowed to delete this automation id
|
||||
if not automation.id.startswith(f"automation_{user.uuid}_"):
|
||||
raise ValueError("Invalid automation id")
|
||||
raise ValueError(f"Invalid automation id: {automation.id}")
|
||||
|
||||
django_job = DjangoJob.objects.filter(id=automation.id).first()
|
||||
execution = DjangoJobExecution.objects.filter(job=django_job, status="Executed")
|
||||
@@ -2000,11 +2000,11 @@ class AutomationAdapters:
|
||||
# Perform validation checks
|
||||
# Check if user is allowed to retrieve this automation id
|
||||
if is_none_or_empty(automation_id) or not automation_id.startswith(f"automation_{user.uuid}_"):
|
||||
raise ValueError("Invalid automation id")
|
||||
raise ValueError(f"Invalid automation id: {automation_id}")
|
||||
# Check if automation with this id exist
|
||||
automation: Job = state.scheduler.get_job(job_id=automation_id)
|
||||
if not automation:
|
||||
raise ValueError("Invalid automation id")
|
||||
raise ValueError(f"Invalid automation id: {automation_id}")
|
||||
|
||||
return automation
|
||||
|
||||
@@ -2013,11 +2013,11 @@ class AutomationAdapters:
|
||||
# Perform validation checks
|
||||
# Check if user is allowed to retrieve this automation id
|
||||
if is_none_or_empty(automation_id) or not automation_id.startswith(f"automation_{user.uuid}_"):
|
||||
raise ValueError("Invalid automation id")
|
||||
raise ValueError(f"Invalid automation id: {automation_id}")
|
||||
# Check if automation with this id exist
|
||||
automation: Job = await sync_to_async(state.scheduler.get_job)(job_id=automation_id)
|
||||
if not automation:
|
||||
raise ValueError("Invalid automation id")
|
||||
raise ValueError(f"Invalid automation id: {automation_id}")
|
||||
|
||||
return automation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user