fix: assistant could create automations past the limit when it gave no schedule (#35382)

When an admin limits how many automations a user may have, a user at that limit could still get the assistant to create more, as long as it left out the schedule. The limit is now checked on every automation the assistant creates, with or without a schedule, exactly as on the Automations page. Admins stay unlimited.

Fixes #35378
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-30 22:37:33 +04:00
1 parent dbf16a4e0d
commit 6ea7d06322
1 file changed
+6 -2
+6 -2
View File
@@ -4551,10 +4551,14 @@ async def create_automation(
(t.model_dump() if isinstance(t, BaseModel) else AutomationSchedule.model_validate(t).model_dump())
for t in triggers or []
]
for i, trigger in enumerate(triggers):
try:
await check_automation_limits(__request__, user, None, None, is_create=True)
except HTTPException as e:
return JSONCodec.dumps({'error': e.detail})
for trigger in triggers:
try:
await validate_rrule(trigger['rrule'], tz=user.timezone)
await check_automation_limits(__request__, user, trigger['rrule'], None, is_create=i == 0)
await check_automation_limits(__request__, user, trigger['rrule'], None)
except ValueError as e:
return JSONCodec.dumps({'error': f'Invalid schedule: {e}'})
except HTTPException as e: