Skip to content

Commit 58ef06a

Browse files
fix(team): add name dedup check to service-layer rename_agent
The HTTP API route calls service.rename_agent directly, which writes to DB without going through the scheduler's dedup guard. This adds the same normalize + uniqueness check at the service layer so that frontend-triggered renames are also protected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1dfeabe commit 58ef06a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

crates/aionui-team/src/service.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,21 @@ impl TeamSessionService {
473473
.ok_or_else(|| TeamError::TeamNotFound(team_id.into()))?;
474474
let mut team = Team::from_row(&row)?;
475475

476+
let normalized = crate::scheduler::normalize_name(name);
477+
if normalized.is_empty() {
478+
return Err(TeamError::InvalidRequest(
479+
"rename_agent.name is empty after normalization".into(),
480+
));
481+
}
482+
483+
// Uniqueness check against all other agents in the team.
484+
let has_conflict = team.agents.iter().any(|a| {
485+
a.slot_id != slot_id && crate::scheduler::normalize_name(&a.name) == normalized
486+
});
487+
if has_conflict {
488+
return Err(TeamError::DuplicateAgentName(name.to_owned()));
489+
}
490+
476491
let agent = team
477492
.agents
478493
.iter_mut()

0 commit comments

Comments
 (0)