Repository navigation
Description
Summary
Managing an automation is scoped to (user_id, org_id), but running one is scoped to org_id alone — and the scheduler is scoped to neither. An automation created by one account therefore fires on every event for its whole org, while being invisible and unmanageable to every other member of that org.
Where
| Path | Scoping |
|---|---|
GET /automations (router.py, list_automations) |
user_id == caller AND org_id == caller's org AND deleted_at IS NULL |
get / patch / delete (router.py, _get_user_automation) |
same filter → 404 for any other member |
POST /automations/runs/{run_id}/cancel (router.py, cancel_run) |
403 "Not your automation" |
event matching (utils/webhook.py, find_matching_automations) |
org_id + enabled + deleted_at — no user_id |
scheduler claim (scheduler.py) |
enabled + deleted_at only — no org, no user |
Impact
When a shared or service account owns an org's automations, no other member of that org can see, disable or delete them — including org admins. There is no org-wide listing endpoint (every route in router.py is owner-scoped), so the automation simply does not appear anywhere in the UI while it continues to act on the org's repositories and post under the org's bot identity.
The failure mode is particularly confusing: because the automation is absent from the automations page, it reads as "already deleted" while it is in fact still running. The only remedies today are authenticating as the exact owning account with that org selected, or writing to the database directly.
Diagnosing this is harder than it should be
last_triggered_at is written only by the polling path (utils/run.py, create_pending_run). The event path (utils/webhook.py, create_automation_run) never writes it, so an event-triggered automation reports last_triggered_at = NULL forever regardless of how often it fires.
Any query that ranks by that column to find "currently active" automations will silently miss every event-triggered one. automation_runs.created_at is the only reliable signal. It would help either to write last_triggered_at on the event path too, or to document that it is polling-only.
Reproduction
- Org
Owith membersAandB. Acreates an event-triggered automation inO.- As
B— any role, including org admin — withOselected:GET /automations→ the automation is not listedDELETE /automations/{id}→404 Automation not foundPOST /automations/runs/{run_id}/cancel→403 Not your automation
- Deliver a matching event for org
O→ the automation runs normally.
Possible directions
- Scope management by
org_id, gating mutations on an org-level permission, rather than by owner identity; or - keep owner-scoping for writes but add an org-wide read plus an admin disable path; or
- at minimum, surface automations belonging to the caller's org that the caller cannot manage, so they are at least discoverable.
Separately, it is worth deciding whether the scheduler should be org-filtered at all — today it claims across every org.
Activity
fix: scope automation management to the org instead of the owner (#399)
all-hands-bot commentedon Oct 13, 2026
[Automatic Post]: This issue has had no activity for 46 days (labels: none). Could someone take a look when they have a chance and help figure out next steps?
Generated by OpenHands automation on behalf of the user.