Guard against duplicate agent_ids across agents#66
Merged
even-steven merged 2 commits intoJun 12, 2026
Merged
Conversation
- Backend: add CheckAgentIDConflict to AgentsRepo; call it in POST and PATCH /admin/agents handlers, returning 409 with a descriptive message when a submitted agent_id is already owned by a different agent - Backend: add ORDER BY id to GetByAgentID so resolution is deterministic even if duplicates exist in the DB - Backend: deduplicate within parseAgentIDs to prevent badge inflation when the same ID appears twice in one agent's array - UI: client-side conflict validation in CreateAgentModal and EditAgentModal before the API call fires; error lists each conflicting ID and the name of the agent that owns it - UI: extract API response body in errorMessage helper so 409 (and other backend errors) show the human-readable message instead of the raw axios status line - UI: console.warn in agentByAgentID map when a duplicate is detected Co-authored-by: Cursor <cursoragent@cursor.com>
|
This pull request has been linked to Shortcut Story #16755: When adding a client_id to an agent ensure unique. |
Move CheckAgentIDConflict before the UpdateEnabled call so we validate all inputs before making any writes, per PR review feedback. Co-authored-by: Cursor <cursoragent@cursor.com>
mdeyell-valid-mind
approved these changes
Jun 12, 2026
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.
Summary
CheckAgentIDConflictadded toAgentsRepo; called in bothPOSTandPATCH /api/v1/admin/agentsbefore writing — returns409 Conflictwith a message naming the conflicting ID and its owner agent.GetByAgentIDnow includesORDER BY idso behaviour is consistent if duplicates somehow reach the DB.parseAgentIDsdeduplicates within a single agent's array, preventing badge-count inflation.CreateAgentModalandEditAgentModalcheck the cached agent list before submitting; on conflict the error alert lists each duplicate ID and the agent that owns it (e.g. vmclient is already in use by "AMP").errorMessagehelper now preferserr.response.data.error.message(the API body) over the raw axios status line, so backend errors like409surface their human-readable text.agentByAgentIDinInvocations.tsxlogs aconsole.warnwhen a collision is detected.Test plan
go test ./internal/...passesMade with Cursor