Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: make chat model sharing work for sharers without directory access - #28703

Merged
mtojek merged 2 commits into
release/2.37from
backport/28542-to-2.37
Aug 27, 2026
Merged

fix: make chat model sharing work for sharers without directory access#28703
mtojek merged 2 commits into
release/2.37from
backport/28542-to-2.37

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-pick of #28542

Original PR: #28542 — fix: make chat model sharing work for sharers without directory access
Merge commit: d0e2234
Requested by: @ethanndickson

Cherry-pick of d0e2234 onto release/2.37 had conflicts.
To resolve:
  git fetch origin backport/28542-to-2.37
  git checkout backport/28542-to-2.37
  git cherry-pick -x -m1 d0e2234
  # resolve conflicts
  git push origin backport/28542-to-2.37
@github-actions github-actions Bot added the cherry-pick/v2.37 Cherry-pick PR targeting release/2.37 label Aug 27, 2026
@github-actions
github-actions Bot requested a review from ethanndickson August 27, 2026 09:49
#28542)

This is a bug fix. Chat model sharing UAT (main @ 3c32408) found two
bugs when a delegated "Model Sharer" role holds only
`chat_model_config:read` + `chat_model_config:share`:

This state is reachable entirely through the UI in a normal
least-privilege setup:

1. An org admin restricts **Organization Settings → Workspace Sharing**
to `none` or `service_accounts`.
2. Under **Organization → Roles**, they create a custom role with only
the advanced permissions `chat_model_config:read` and
`chat_model_config:share`.
3. Under **Organization → Members**, they assign that role to the person
responsible for managing model access.
4. An admin creates a chat model and may initially share it with a
group.
5. The delegated sharer signs in, opens **AI Settings → Models → [model]
→ Share model**, where the failures below occur.

- **UAT-05 / UAT-08:** with workspace sharing set to `none`, the sharing
dialog errored out entirely ("Resource not found or you do not have
access to this resource"). The sharer couldn't view, add, or even remove
grants.
- **UAT-04:** with workspace sharing set to `service_accounts`, existing
group grants rendered as raw UUIDs, and groups didn't appear in the
add-principal search.

Both have the same cause. The ACL GET returned bare UUID→role maps, so
to display names (and to power its add-principal search) the dialog
called the generic org directory APIs: list organization members and
list groups. Those APIs require `organization_member:read` and
`group:read`, which the sharer role doesn't have. Ordinary members only
get them as a side effect of a *different* feature:
`OrgMemberPermissions` grants member read when the org's workspace
sharing mode isn't `none` (so users can pick coworkers to share a
workspace with), and group read only when it's `everyone`. The chat
dialog was silently borrowing those workspace-sharing permissions, so it
only worked when that unrelated org setting happened to grant them:

- `none`: no member read → dbauthz rejects the member listing → the
dialog's query chain 404s and everything blanks (UAT-05/08).
- `service_accounts`: member read but no group read → the group listing
silently filters to empty → group grants can't be resolved past their
UUIDs (UAT-04).

In short: an org setting about who can share workspaces was deciding
whether a delegated sharer could manage a chat model ACL.

Stop borrowing directory permissions entirely; authorize everything
through the model's own share permission, using the two patterns the
repo already has for ACL editors:

- **Hydrate the ACL GET** to return resolved users and groups instead of
UUID maps, like `workspaceACL` and the per-chat ACL already do. Fixes
the raw UUIDs.
- **Add `GET .../acl/available`** returning assignable org members and
groups for the autocomplete, modeled directly on
`templateAvailablePermissions` (same query semantics, same
share-gate-then-system-context lookup that every sibling ACL endpoint
uses). Fixes candidate discovery. The new endpoint exists only because
the dialog has no permission-safe way to enumerate principals today; it
is plumbing for the fix, not a new feature.

This is exactly how template sharing already solves the same problem:
`templateACL` returns hydrated principals, and
`templateAvailablePermissions` gates on the template then does the
lookups under a system context because, per its own comment, "the caller
might not have permission to read all users". We differ from the
template version only where newer conventions exist:

| | Template | This PR |
|---|---|---|
| Gate | `ActionUpdate` on the template (predates `share`) |
`ActionShare` on the model, matching the workspace/chat/MCP ACL
endpoints |
| User candidates | Site-wide `GetUsers` | Non-system members of the
model's org only |
| Group hydration | Full member rosters | Member counts, batched in one
query |

The dialog now runs off the hydrated ACL plus the new endpoint, so all
three sharing modes take the same code path, and a discovery failure no
longer blanks existing grants. `OrgMemberPermissions`, the directory
APIs, and the PATCH (still a sparse UUID→role delta) are untouched.

+1274/−191, but only about a third is product code:

- **Product (~450):** the two endpoints and hydration helpers
(`exp_chats_model_acl.go`, ~240), the dialog rework plus a new colocated
autocomplete component (~200), and SDK/site API plumbing (~60).
- **Tests (~625):** backend tests updated to hydrated shapes plus new
tests that reproduce the two failing UAT sharing modes end-to-end
(+418), rewritten and new story play tests (+198), and query/mock
updates.
- **Generated (~200):** swagger, apidocs, `typesGenerated.ts`, API
reference docs.

Depends on #28498 (stacked on the `/api/v2` chat API promotion; the new
endpoint is registered under both prefixes like its siblings).

---------

Co-authored-by: Michael Suchacz <[email protected]>
(cherry picked from commit d0e2234)
@github-actions

Copy link
Copy Markdown
Contributor Author

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@ethanndickson ethanndickson changed the title [CONFLICT] fix: make chat model sharing work for sharers without directory access (#28542) fix: make chat model sharing work for sharers without directory access (#28542) Aug 27, 2026
@ethanndickson ethanndickson changed the title fix: make chat model sharing work for sharers without directory access (#28542) fix: make chat model sharing work for sharers without directory access Aug 27, 2026
@ethanndickson
ethanndickson requested a review from mtojek August 27, 2026 10:19
@mtojek
mtojek merged commit e1f017e into release/2.37 Aug 27, 2026
41 of 43 checks passed
@mtojek
mtojek deleted the backport/28542-to-2.37 branch August 27, 2026 10:30
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.37 Cherry-pick PR targeting release/2.37

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants