mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 18:15:34 +00:00
refactor(ws/teams): accept agent_key or UUID + fix handleAddMember error leak
Two teams handlers migrated to resolveAgentUUIDCached: - handleRemoveMember (params.AgentID) accepts agent_key or UUID. - handleTaskAssign (params.AgentID) accepts agent_key or UUID. handleAddMember already used resolveAgentInfo, but leaked raw store errors via "agent: " + err.Error() on resolution failure. H10 fix replaces the leak with i18n.MsgInvalidID — no more store schema info surfacing to WS clients. Phase 3 of agent identity hardening.
This commit is contained in:
1 parent
ef730ac84a
commit
6bbe1b66ff
2 files changed
+7
-4
No files matched your search
@@ -52,10 +52,11 @@ func (m *TeamsMethods) handleAddMember(ctx context.Context, client *gateway.Clie
|
||||
return
|
||||
}
|
||||
|
||||
// Resolve agent
|
||||
// Resolve agent — accepts agent_key or UUID. H10 fix: return i18n error instead
|
||||
// of leaking raw store error (was: "agent: " + err.Error()).
|
||||
ag, err := resolveAgentInfo(ctx, m.agentStore, params.Agent)
|
||||
if err != nil {
|
||||
client.SendResponse(protocol.NewErrorResponse(req.ID, protocol.ErrInvalidRequest, "agent: "+err.Error()))
|
||||
client.SendResponse(protocol.NewErrorResponse(req.ID, protocol.ErrInvalidRequest, i18n.T(locale, i18n.MsgInvalidID, "agent")))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -134,7 +135,8 @@ func (m *TeamsMethods) handleRemoveMember(ctx context.Context, client *gateway.C
|
||||
client.SendResponse(protocol.NewErrorResponse(req.ID, protocol.ErrInvalidRequest, i18n.T(locale, i18n.MsgInvalidID, "teamId")))
|
||||
return
|
||||
}
|
||||
agentID, err := uuid.Parse(params.AgentID)
|
||||
// Phase 3 FR-1: accept agent_key or UUID via cache-aware resolver.
|
||||
agentID, err := resolveAgentUUIDCached(ctx, m.agentRouter, m.agentStore, params.AgentID)
|
||||
if err != nil {
|
||||
client.SendResponse(protocol.NewErrorResponse(req.ID, protocol.ErrInvalidRequest, i18n.T(locale, i18n.MsgInvalidID, "agentId")))
|
||||
return
|
||||
|
||||
@@ -151,7 +151,8 @@ func (m *TeamsMethods) handleTaskAssign(ctx context.Context, client *gateway.Cli
|
||||
client.SendResponse(protocol.NewErrorResponse(req.ID, protocol.ErrInvalidRequest, i18n.T(locale, i18n.MsgInvalidID, "taskId")))
|
||||
return
|
||||
}
|
||||
agentID, err := uuid.Parse(params.AgentID)
|
||||
// Phase 3 FR-1: accept agent_key or UUID for assignee.
|
||||
agentID, err := resolveAgentUUIDCached(ctx, m.agentRouter, m.agentStore, params.AgentID)
|
||||
if err != nil {
|
||||
client.SendResponse(protocol.NewErrorResponse(req.ID, protocol.ErrInvalidRequest, i18n.T(locale, i18n.MsgInvalidID, "agentId")))
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user