Repository navigation
Studio: let the owner share a connection with every account - #14365
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (2)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70519403af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| model_id = (model_id or "").strip().lower() | ||
| candidates = {model_id, model_id.split(":", 1)[0]} | ||
| return any(fnmatchcase(candidate, pattern) for candidate in candidates for pattern in allowlist) |
There was a problem hiding this comment.
Strip only the final model tag separator
For model IDs containing another colon before the tag, such as a registry-qualified host:5000/org/model:latest, splitting at the first colon produces host instead of the untagged host:5000/org/model. An allowlist containing the actual untagged model consequently hides and rejects it even though tag suffixes are meant to be ignored. Use the final colon when deriving the tagless candidate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Model access entries can never contain a colon: normalize_model_allowlist cuts each entry at its first colon, so an untagged candidate like host:5000/org/model could not match any entry whichever colon is split.
… filter their capabilities [skip ci]
…ision connections, match ~ aliases
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3128bb0056
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| async with provider_config_guard( | ||
| provider_id, shared_by_owner = bool(config.get("shared_by_owner")) | ||
| ): |
There was a problem hiding this comment.
Recheck routing after resolving the shared credential
With multiple backend processes, this per-event-loop lock cannot coordinate an owner update in another process: STT can read the old URL in current, the owner can atomically replace the URL and key, and the subsequent credential lookup then returns the new key, which is sent to the old endpoint because this path has no final row check. Fresh evidence beyond the earlier in-process concern is that the TTS and image paths explicitly perform a post-key reread for cross-process edits, while STT, chat, /models, /model-capabilities, and /test do not; these paths need the same final routing comparison (or a single consistent database snapshot).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed here: the STT block (read under the guard, then resolve the key, no final row check) is identical on main for an account's own connections, and this PR only adds the shared flag to the guard call. The URL in a shared row is set by the owner alone, so a managed account cannot steer the key anywhere. A cross-process final recheck for STT, chat and the listing routes is worth a separate change.
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Review + reproduction evidencePinned review: I reproduced the shared connection flow on the merge base
Conclusion: real gap from #14196, now working end to end. The owner's key never leaves the server, and other accounts cannot change a shared row or reach models the owner did not enable. Two small follow-ups are inline. |
NilayYadav
left a comment
There was a problem hiding this comment.
Thank you for the PR! The goal of this PR is to let the installation owner set up an external connection once and share it with every managed account, with the owner's Model access list applying to connection models. As a summary, this PR adds a shared flag on saved connections, lets managed accounts read shared rows and resolve the owner's key server-side only, refuses edits and unenabled models from other accounts, and adds a "Share with all accounts" switch and a "Shared by owner" tag in Settings > Connections.
| Reviewers | Severity | Finding |
|---|---|---|
| 1/4 | Medium | The OpenAI code execution section still mounts on a connection shared by the owner, so its container list and poll hit the new 403 |
| 1/4 | Low | Capabilities fetched through a shared row are filtered to the shared models but cached for the whole provider type |
See inline comments for details and suggested fixes.
| status_code = 400, | ||
| detail = "OpenAI container management requires a saved OpenAI provider.", | ||
| ) | ||
| if config.get("shared_by_owner"): |
There was a problem hiding this comment.
[1/4 reviewers] This 403 is right, but the chat settings sheet still mounts OpenAICodeExecSection for a shared OpenAI row: showOpenAICodeExecSection in chat-settings-sheet.tsx only checks the provider type, model and base URL, and hasCredential is true because has_api_key is true for the shared row. The section lists containers on mount, on its poll and on every tab focus, so a managed account on a shared OpenAI connection with a code-exec model gets a "Failed to list containers" toast each time. Hiding the section for sharedByOwner rows matches this guard (chat-settings-sheet.tsx is outside the diff, so the change is below):
const showOpenAICodeExecSection =
activeExternalProvider != null &&
+ !activeExternalProvider.sharedByOwner &&
providerSupportsBuiltinCodeExecution(| shared_models = _shared_target_models(payload) | ||
| capabilities = await _list_model_capabilities(payload, via_api_key) | ||
| if shared_models is not None: | ||
| capabilities = [entry for entry in capabilities if entry.get("id", "") in shared_models] |
There was a problem hiding this comment.
[1/4 reviewers] This list is now limited to the models the owner enabled, which is what a shared row should expose, but the frontend stores capability results per provider type with a 24 hour TTL. If the shared row is fetched first, an account's own connection of the same type (or a second shared one) then misses metadata such as output limits and mandatory reasoning for every model outside that set until the TTL runs out. Either skip the TTL shortcut and merge instead of replace for shared rows in sync-external-providers.ts / model-catalog.ts, or keep the shared fetch out of the provider-wide cache:
- if (fetchedAt != null && Date.now() - fetchedAt < MODEL_CATALOG_TTL_MS) continue;
+ if (!provider.sharedByOwner && fetchedAt != null &&
+ Date.now() - fetchedAt < MODEL_CATALOG_TTL_MS) continue;|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
That run merged into |
…mpile packing test off leaked env (#14425) ## Problem Two tests on main fail in CI for reasons in the tests, not the product. They are red on unrelated PRs, for example #14409 and #14365. **1. `tests/python/test_v100_fullft_precision.py` (10 tests, `Repo tests (CPU, studio)`)** ``` tests/python/test_v100_fullft_precision.py:80: in _decide exec(CODE, {"torch": torch, "os": os}, {"args": args, "model": model}) E NameError: name 'args' is not defined ``` The test runs the `mixed_precision` template from `unsloth/models/rl.py` with separate globals and locals dicts. #14394 added `_unsloth_precision_requested = tuple(getattr(args, k, False) for k in (...))` to that template. In the generated trainer this runs inside a function, where the generator sees `args`, so the product is fine. A generator inside `exec` with a separate locals dict cannot see those locals, so the test raises `NameError`. **2. `tests/test_legacy_block_compile_install.py::test_packed_calls_keep_the_unsloth_layer_forward` (`Repo tests (CPU, rest)`)** ``` tests/test_legacy_block_compile_install.py:105: in test_packed_calls_keep_the_unsloth_layer_forward E assert [] ``` The test (from #14398) expects an unpacked call to go through the compiled block. `_block_compile._wrap` keeps every call on the stock forward when `UNSLOTH_COMPILE_DISABLE` is `1`, `UNSLOTH_BLOCK_COMPILE` is `0`, or `UNSLOTH_FORCE_FLOAT32` is `1`. Eight test modules run `os.environ.setdefault("UNSLOTH_COMPILE_DISABLE", "1")` at import time, so the result depends on which modules a worker collected. The test passes alone and fails with any of those variables set. ## Fix Test only: - `test_v100_fullft_precision.py`: `exec` the template in one namespace, as in the trainer's function scope. Results are still read from `args` and the environment. - `test_legacy_block_compile_install.py`: the packing test clears the three variables with `monkeypatch.delenv` before wrapping. ## Verification - `test_v100_fullft_precision.py`: on main 10 failed (the `NameError` above); with this change 10 passed. - `test_legacy_block_compile_install.py` on main: - with any one of `UNSLOTH_COMPILE_DISABLE=1`, `UNSLOTH_BLOCK_COMPILE=0` or `UNSLOTH_FORCE_FLOAT32=1` set: 1 failed (the packing test), 5 passed; - with this change: 6 passed in each of those three cases and with none set.
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts



Fixes #14196
What this does
On an install with more than one account, every person had to add the same external connection (for example a household Gufo, Ollama or llama.cpp server, or a hosted API key) again in their own account, and the owner's per-account Model access list did not apply to connection models at all.
The installation owner can now turn on Share with all accounts when adding or editing a connection in Settings > Connections:
unsloth/*,unsloth/Qwen3-8B-GGUF,gpt-4o, a:tagsuffix is ignored). Disallowed models are hidden from the list and refused (403) on chat, speech, transcription, image and research requests. A shared connection with no allowed model is hidden for that account.container_auto.Each account's own connections are unchanged: they still come first, keep their own keys, and are not limited by Model access.
A shared connection to a local or LAN address uses the existing owner switch in Settings for managed accounts (Local and network connections), the same rule as an account's own connections. That switch stays the single place where the owner decides whether other accounts can reach this machine's network.
Compatibility
sharedfield is sent). The backend only reads the owner's store from a managed-account context, so the owner's request path is unchanged.shared INTEGER NOT NULL DEFAULT 0column, added idempotently like the existing migrations. Every existing connection stays private. An older build reading the same database ignores the column, so a downgrade keeps working and nothing is shared.Tests
studio/backend/tests/test_account_shared_connections.py: sharing, owner-key resolution server-side only, read-only for other accounts, owner-only sharing, no sharing of a subscription sign-in, unshare revokes, own connections first, Model access filtering and refusal, hidden when nothing is allowed, refusing to share a credential-bearing URL, a real loopback upstream receiving the owner's bearer through a shared connection, a connection check that makes no model request and quotes no URL, OpenAI containers refused, readers sharing the owner's lock, the private address switch still applying, and an upgrade from a pre-sharing table.studio/frontend/tests/connections-shared-by-owner.test.ts: toggle shown only to the owner with another account, nosharedfield for single-account saves, no edit/delete on a row shared by the owner, sync never writes back to it.Screenshots
Before (merge base) and after (this PR), two fresh Studio installs. The owner saves a custom connection "Household Gufo" with sharing on, then a managed account "alice" opens Settings > Connections.
Owner editing the connection: the new "Share with all accounts" switch.
Alice's Connections page: before, she has no connections and the add form opens; after, the owner's connection is listed with a "Shared by owner" tag and only the Check button (no edit or delete).