Repository navigation
Description
Summary
Removing a provider credential does not touch the settings that name that provider's models, and the delete dialog does not say that those settings will change. Only the embedding model is checked. Governance rules (default models, model access), and the other pins that store a provider and model (vision, image generation, standard agent), keep pointing at models that are no longer offered. The editors then show these entries in a degraded way, or not at all, while the stored rule keeps them. The report was that the UI "seems to break" after a provider was removed; the exact symptoms were not captured, so everything below is read from the code, not observed.
What the code does today (main at 2741e5b)
The delete.
services/platform/backend/domains/provider_credentials/service.ts:1076-1113(deleteCredential) deletes the row and writes an audit entry. Before that it callsassertCredentialUnused(:958-965), which askscredentialDependents(:906-937).CredentialDependentis the single value'embedding'(:893). Nothing else is looked up, so no rule, pin or agent can make the delete refuse or warn.- The dialog side mirrors it:
useDeleteWarninginservices/platform/app/features/settings/providers/credential-adapter.tsx:550-557warns only for the embedding model (providers.credential.deleteEmbeddingWarning), anddeleteWarning(:542-545) only for the last credential of a custom provider.
What stores a provider and model, and survives the delete (schemas in packages/shared/src/schemas/governance.ts):
| Setting | Stored | Lines |
|---|---|---|
| Default models, per scope | providerName + modelId |
:479-485 |
| Model access, allow / block lists | bare model ids | :746-751 |
| Vision model | providerSlug + modelId |
:508-512 |
| Image generation | providerSlug + modelId |
:542-547 |
| Standard agent | providerSlug + modelId |
:600-607 |
| Project agents | model (+ modelProvider) |
packages/shared/src/schemas/projects.ts:173, managed-configuration.ts:71 |
What the editors do with an entry whose provider is gone. The provider list they read (hooks/model-catalog.ts, useListProviders) holds only providers with an active credential, so a removed provider is simply absent:
- Default models (
services/platform/app/features/settings/governance/components/default-model-editor.tsx). The table falls back to the raw slug and raw id (resolveProviderName/resolveModelName,:588-606), so the row reads like a working one. The edit dialog's provider and model selects are fed from the same list (:225-238), so the stored value has no matching option. Whether the select renders blank or the raw value was not examined. - Model access (
components/model-access-editor.tsx). Options come only from live providers (:422-440), andMultiSelectbuilds its chips by looking each stored value up among the options and dropping the misses (packages/ui/src/components/forms/multi-select.tsx:225-231). A rule allowing only a removed provider's models therefore shows no chips, yet still stores them, and the rules table names them by raw id (resolveModelNames,:704-715). In allowlist mode such a rule allows nothing that exists, with nothing on screen saying why. - The backend tolerates some of it on purpose: a pinned default that is no longer servable degrades to automatic selection with a log warning (
services/platform/backend/core/lib/providers/resolve_chat_model.ts, "falling back to automatic selection"), and the vision lane warns and falls back (resolve_vision_model.ts:186-211,:288). The admin sees neither; the warnings are in the server log.
A second credential for the same provider keeps the provider alive, so this concerns the last active credential of a provider (or a disabled one: useListProviders also drops providers without an active credential).
Observed vs. not examined
- Not examined in a browser: what each editor renders for a stale entry, whether any of it throws, and what the UI does on the next save of a rule whose entries are stale (does the save keep, drop or reject them).
- Not examined: the other places a model is chosen (automations, tasks, project agents, spend or routing rules): whether they validate a stored model against the live catalog, and what an admin sees when one no longer resolves.
- Not examined: what happens to a thread, task or automation currently running on the removed provider's model.
- Disabling a credential (status
disabled) and a catalog that fails to load both make a provider disappear from the same list; whether they should be treated like removal was not examined.
Constraints
- Org configuration is files, not tables; the dependents live in several config files and in project agent rows, so one lookup would span both.
- The embedding guard exists because indexing and search go down org-wide; it refuses outright. The other pins degrade (Auto, vision), so a refusal may be the wrong strength for them.
- Credential deletes are audited (
provider_credential.deleted); a cleanup that rewrites rules would need an audit entry of its own. - The admin's rules are the admin's data; rewriting them silently is the kind of change that has to be visible.
- User-visible strings go to every locale.
Options (no preference stated)
- Warn in the delete dialog. Extend
credentialDependentsbeyond'embedding'to list the settings that name this provider's models (rules, pins, project agents) and show them in the dialog before the delete, as the embedding warning already does. The delete still goes through. - Refuse like embedding. The same lookup, but the server answers 409
CREDENTIAL_IN_USEfor some or all of them, naming what to move first. - Clean up on delete. Remove the rules and pins that name the provider (or reset them to automatic) in the same transaction, listing what changed in the audit entry and in the dialog.
- Make stale entries visible. Leave the delete as it is and have the editors show an entry whose provider is gone ("provider removed"), keep its chip in the Model access field, and offer to remove it.
- A settings health surface. A list of settings that point at something no longer served, reachable from Settings, independent of what removed it.
These combine: 1 + 4 changes no stored data; 3 changes data and wants 1 first.
Questions
- Which of the pins should block a delete, which should only warn, and which should be reset?
- Should disabling a credential carry the same warning as removing it?
- Should a model access rule be able to name a provider (see bug(platform): Model access repeats a model per provider without naming it; the rows check together and outlive a search #5178), so that "this provider's models" is one thing a delete can find?
Related
- bug(platform): Model access repeats a model per provider without naming it; the rows check together and outlive a search #5178: the Model access list shows no provider and stores bare ids, so a rule cannot say which provider a model came from.
- Bug: Auto can pick a provider that is out of credit, and the turn fails instead of using the other one #5339: Auto picks a provider whose key is out of credit.
- bug(platform): Embedding model Save is on with empty fields after a provider change, and off without a reason once a model is picked #5182: the embedding Save is stale or dead after a provider switch (the one dependency that is guarded).
Activity
fix(platform): name the settings a provider's removal leaves behind
test(platform): match getPolicy's options argument in sandbox tests
test(platform): match getPolicy's options argument in sandbox tests