Skip to content

Commit a007147

Browse files
committed
minor fix in edit a2a update
Signed-off-by: Satya <[email protected]>
1 parent 836eb9a commit a007147

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mcpgateway/services/a2a_service.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,19 +602,20 @@ async def update_agent(
602602
raise PermissionError("Only the owner can update this agent")
603603
# Check for name conflict if name is being updated
604604
if agent_data.name and agent_data.name != agent.name:
605+
new_slug = slugify(agent_data.name)
605606
visibility = agent_data.visibility or agent.visibility
606607
team_id = agent_data.team_id or agent.team_id
607608
# Check for existing server with the same slug within the same team or public scope
608609
if visibility.lower() == "public":
609610
# Check for existing public a2a agent with the same slug
610-
existing_agent = db.execute(select(DbA2AAgent).where(DbA2AAgent.slug == agent_data.slug, DbA2AAgent.visibility == "public")).scalar_one_or_none()
611+
existing_agent = db.execute(select(DbA2AAgent).where(DbA2AAgent.slug == new_slug, DbA2AAgent.visibility == "public")).scalar_one_or_none()
611612
if existing_agent:
612-
raise A2AAgentNameConflictError(name=agent_data.slug, is_active=existing_agent.enabled, agent_id=existing_agent.id, visibility=existing_agent.visibility)
613+
raise A2AAgentNameConflictError(name=new_slug, is_active=existing_agent.enabled, agent_id=existing_agent.id, visibility=existing_agent.visibility)
613614
elif visibility.lower() == "team" and team_id:
614615
# Check for existing team a2a agent with the same slug
615-
existing_agent = db.execute(select(DbA2AAgent).where(DbA2AAgent.slug == agent_data.slug, DbA2AAgent.visibility == "team", DbA2AAgent.team_id == team_id)).scalar_one_or_none()
616+
existing_agent = db.execute(select(DbA2AAgent).where(DbA2AAgent.slug == new_slug, DbA2AAgent.visibility == "team", DbA2AAgent.team_id == team_id)).scalar_one_or_none()
616617
if existing_agent:
617-
raise A2AAgentNameConflictError(name=agent_data.slug, is_active=existing_agent.enabled, agent_id=existing_agent.id, visibility=existing_agent.visibility)
618+
raise A2AAgentNameConflictError(name=new_slug, is_active=existing_agent.enabled, agent_id=existing_agent.id, visibility=existing_agent.visibility)
618619
# Update fields
619620
update_data = agent_data.model_dump(exclude_unset=True)
620621
for field, value in update_data.items():
@@ -637,7 +638,6 @@ async def update_agent(
637638
db.refresh(agent)
638639

639640
logger.info(f"Updated A2A agent: {agent.name} (ID: {agent.id})")
640-
641641
return self._db_to_schema(db=db, db_agent=agent)
642642
except PermissionError:
643643
db.rollback()

0 commit comments

Comments
 (0)