Repository navigation
fix(sharing): let a non-owner admin add themselves to an agent's access - #4762
mayuriphad wants to merge 2 commits into
Conversation
The share route and SharingMixin.share_agent refused any share whose target was the caller's email. That was meant to stop an owner sharing an agent that is already on their roster, but it also blocked a non-owner admin from adding themselves, which is the only way an agent reaches their Workspace (the admin role does not widen the roster). Compare the target against the agent owner's email instead, in both layers. The owner is still refused, now with a message that says why. A self-add sends no invitation email and is audited like any other share. Fixes Abilityai#4666 Signed-off-by: mayuriphad <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
merge-train note: validated at |
|
merge-train: not riding this train after all; rides the next one once fixed. Tier 1 ran for the first time on this head (
The Gate 1 ruling stands: this is accepted as the backend half of #4666, with the UI criteria in #4768. |
The two DB reads added to share_agent_endpoint ran on the event loop and grew routers/sharing.py past the Abilityai#4674 sync-on-loop baseline. Hop both to a thread and read the caller's email once; the file now has 19 blocking calls, so the baseline drops from 20 to 19. Signed-off-by: mayuriphad <[email protected]>
|
Fixed in 9ce1b7c. Both new reads in |
Description
A non-owner admin could not add themselves to an agent's access.
share_agent_endpointandSharingMixin.share_agentboth refused any share whose target matched the caller's email. The refusal is meant to stop an owner sharing an agent that is already on their roster. It also blocked a non-owner admin, and for them a self-share is the only way an agent reaches their Workspace, because the admin role does not widen the roster.Both layers now compare the target with the agent owner's email:
db/agent_settings/sharing.py: a newget_agent_owner_email(agent_name), also exposed ondatabase.db.share_agentrefuses a share with the owner, whoever calls it. A related problem is gone too: ondev, an admin could share an agent with its own owner, which writes a redundant row.routers/sharing.py: the owner gets400 Cannot share an agent with yourself: you own it, so it is already on your Workspace. An admin targeting the owner gets400 Cannot share an agent with its owner: .... A self-add skipsinvite_on_share, so it sends no email and returnsinvitation: "not_needed". It is still audited like any other share, and still behindrequire_interactive/reject_non_interactive_principal.This PR is backend only. I left the two UI items in the acceptance criteria for a follow-up: the "Add myself" action on the access UI and the admin empty-state copy in
Portal.vue. With this change, an admin can already add themselves by entering their own email in the existing share field.Written with an AI assistant. I have reviewed the change and can explain every line.
Related Issue
Fixes #4666
Journey Impact
Journey Impact: none: corrects which email the existing share refusal compares against; no new or changed user promise in the journey catalog
Type of Change
Testing
tests/unit/test_4666_admin_self_share.pydrives the real sharing router and DB layer over the unit DB, using the same harness astest_ent459_operator_invite.py. It covers:test_837_workspace_only_floor.py: its fake DB gainsget_agent_owner_email, which the route now calls.I ran these on a Linux GitHub Actions job (Python 3.13,
tests/requirements-test.txt). The job ran the new file, the touched test and the other share and roster tests:test_ent459_operator_invite.py,test_ent719_inline_layer_matches_route_rule.py,test_ent357_workspace_owned_roster.pyandtest_4579_credential_primary_reach.py. Result: 210 passed.Mutation: with
src/reverted todev,test_4666_admin_self_share.pygives 6 failed, 2 passed. The 2 that still pass are the owner sharing with an admin and the non-owner 404, which are the controls.Checklist
git commit -s) — required for contributors outside the core team