Repository navigation
fix: scope automation management to the org instead of the owner - #399
Merged
Merged
Conversation
Management endpoints filtered on user_id AND org_id, while event matching filtered on org_id alone and the scheduler on neither. An automation created by one account therefore ran for its whole org while being invisible and unmanageable to every other member: list omitted it, delete returned 404 and cancel returned 403. List, get, patch, delete, tarball, dispatch, runs and cancel now resolve by org_id, gated by the manage_automations permission that already guarded these routes. Template dedupe is org-scoped to match. complete_run and report_run_phase are callbacks from inside the sandbox rather than user actions, so they keep the owner check. Refs #396
Contributor
VascoSch92
marked this pull request as ready for review
August 28, 2026 07:29
Contributor
|
👋 This PR needs a couple of things fixed before OpenHands can review it:
Push an update once this is addressed and this check re-runs automatically. This is an automated check - no AI was used to generate this comment. |
2 similar comments
Contributor
|
👋 This PR needs a couple of things fixed before OpenHands can review it:
Push an update once this is addressed and this check re-runs automatically. This is an automated check - no AI was used to generate this comment. |
Contributor
|
👋 This PR needs a couple of things fixed before OpenHands can review it:
Push an update once this is addressed and this check re-runs automatically. This is an automated check - no AI was used to generate this comment. |
Contributor
|
🚀 Released in 1.9.1. |
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the scoping half of #396.
Problem
Management endpoints filtered on
user_idANDorg_id, while event matching filtered onorg_idalone and the scheduler on neither. An automation created by one account therefore fired for its whole org — acting on the org's repos under the org's bot identity — while being invisible and unmanageable to every other member of that org: it was absent fromGET /automations,DELETEreturned 404, and cancel returned 403. With no org-wide listing endpoint, it read as "already deleted" while still running.This is easy to hit with a shared or service account that owns an org's automations, and the only remedies were authenticating as that exact account or writing to the database.
Change
list,get,patch,delete,tarball,dispatch,runsandcancel_runnow resolve byorg_id._get_user_automationbecomes_get_org_automation; theuser_idpredicate is dropped from the list query and from thecancel_runownership check.Authorization is unchanged: every one of these routes already depends on
require_permission("manage_automations"), which is org-scoped, so dropping the owner predicate does not leave them ungated.user_idis still recorded on create — it just no longer governs access.Template dedupe (
find_existing_template_automation) is org-scoped to match, so enabling a template twice in one org returns the existing automation rather than creating a per-member duplicate.complete_runandreport_run_phaseare callbacks from inside the sandbox rather than user actions, so they keep the owner check.No schema change and no migration —
org_idis already present and indexed.Tests
test_list_automations_includes_other_org_members— a teammate's automation is listedtest_delete_other_org_members_automation— a member can delete a teammate's automationtest_cancel_same_org_other_users_run— a member can cancel a teammate's runtest_cancel_other_users_run_returns_403renamed totest_cancel_other_orgs_run_returns_403; it was always cross-org, and cross-org rejection is unchangedFull unit suite passes (1483). Pre-commit clean: ruff format, ruff lint, pycodestyle, pyright.
Deliberately not included
The
last_triggered_atobservability problem also described in #396 — the event path never writes it, so event-triggered automations reportNULLforever and any query ranking by it to find active automations silently misses them. That is a separate concern; keeping this PR to the access-control change.Follow-up worth considering
The list response has no owner field, so the UI will now show automations without indicating who created them. A small
agent-canvaschange to surface the owner would help.