MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / assertAgentsOwned

Method assertAgentsOwned

internal/httpapi/webhooks.go:152–170  ·  view source on GitHub ↗

assertAgentsOwned verifies every referenced agent_id is owned by the user, mirroring the legacy assertAgentsOwnedByUser (uses ListAgents at filter-list scale ≤50).

(ctx context.Context, userID string, agentIDs []string)

Source from the content-addressed store, hash-verified

150// mirroring the legacy assertAgentsOwnedByUser (uses ListAgents at filter-list
151// scale ≤50).
152func (s *Server) assertAgentsOwned(ctx context.Context, userID string, agentIDs []string) *ErrorEnvelope {
153 if len(agentIDs) == 0 {
154 return nil
155 }
156 agents, err := s.deps.ListAgents(ctx, userID)
157 if err != nil {
158 return NewError(http.StatusInternalServerError, "internal_error", "failed to validate agent filters")
159 }
160 owned := make(map[string]struct{}, len(agents))
161 for i := range agents {
162 owned[agents[i].ID] = struct{}{}
163 }
164 for _, id := range agentIDs {
165 if _, ok := owned[identity.NormalizeEmail(id)]; !ok {
166 return NewError(http.StatusBadRequest, "invalid_request", fmt.Sprintf("filters.agent_ids references an agent you don't own: %q", id))
167 }
168 }
169 return nil
170}
171
172type webhookOutput struct{ Body WebhookView }
173type webhookCreateOutput struct{ Body CreateWebhookResponse }

Callers 1

validateWebhookFieldsMethod · 0.95

Calls 3

NormalizeEmailFunction · 0.92
NewErrorFunction · 0.85
makeFunction · 0.85

Tested by

no test coverage detected