Repository navigation
fix(api): refuse to delete providers, connections and agents that are still used (#434) - #516
Merged
Merged
Conversation
… still used (#434) Providers, connections and agents are referenced from JSON (agent specs, team definitions, environment mappings, worker profiles), so no foreign key stopped a delete: it returned 204 and the dependants failed later at run time with an unrelated-looking error. Skills and worker profiles already refused. - Store: new `in_use` module with "used by" queries. `delete_provider`, `delete_connection` and `delete_agent` lock the row, refuse with the new `StoreError::InUse` while anything refers to it, then delete in the same transaction. Providers: agent model, team and step/node model overrides, worker profiles. Connections: agent connector bindings, team connectionIds and work source, environment mappings, worker profile env mappings. Agents: team steps and workflow nodes, worker profile agent scopes (team run history is still protected by the team_steps key). The bulk agent delete uses the same path, so its preview reports the same conflicts. - API: `InUse` becomes a 409 envelope whose `details` name each dependant (path `usedBy`). A permanent agent delete records what went with it (executions, triggers, tool policies, memory, runtimes, outputs deleted or detached) in the audit entry. New `GET /api/v1/agents/{id}/delete-impact` returns `usedBy` and `removes` for the confirmation dialog. - Web: the agent delete dialogs load the impact first; an agent still in use is not offered for deletion (a message names the dependants), otherwise the dialog lists what is removed. Provider and connection deletes name the dependants when refused. - Docs: agents, connections and providers guides; UI test plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #434.
Summary
Providers, connections and agents are referenced from JSON (agent specs, team
definitions, environment mappings, worker profiles), so no foreign key stopped a
delete: it returned 204 and the dependants failed later at run time with an
unrelated-looking error. Skills and worker profiles already refused.
in_usemodule with "used by" queries.delete_provider,delete_connectionanddelete_agentlock the row, refuse with the newStoreError::InUsewhile anything refers to it, then delete in the sametransaction. Providers: agent model, team and step/node model overrides,
worker profiles. Connections: agent connector bindings, team connectionIds and
work source, environment mappings, worker profile env mappings. Agents: team
steps and workflow nodes, worker profile agent scopes (team run history is
still protected by the team_steps key). The bulk agent delete uses the same
path, so its preview reports the same conflicts.
InUsebecomes a 409 envelope whosedetailsname each dependant(path
usedBy). A permanent agent delete records what went with it(executions, triggers, tool policies, memory, runtimes, outputs deleted or
detached) in the audit entry. New
GET /api/v1/agents/{id}/delete-impactreturns
usedByandremovesfor the confirmation dialog.not offered for deletion (a message names the dependants), otherwise the
dialog lists what is removed. Provider and connection deletes name the
dependants when refused.
Testing
cargo fmt --check,clippy --workspace --all-targets -D warnings: cleancargo test --workspace --no-fail-fastwith a database: 0 failures (189 API integration); newin_use_providers_connections_and_agents_refuse_deletepnpm api:generate --check: passed (newGET /api/v1/agents/{id}/delete-impact)typecheckpassed;test96 passed (2 new inlib/delete-impact.test.ts);pnpm docs:checkpassedNot checked in a browser. Provider and connection dialogs show dependants only after the refusal, not before confirming. Connection references from agent bindings, teams and worker profiles are covered by the queries but not by their own tests. Conflicts with #510 in the generated
openapi.json/schema.d.tsandapi_integration.rs; whichever merges second rerunspnpm api:generate.🤖 Generated with Claude Code