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)
| 150 | // mirroring the legacy assertAgentsOwnedByUser (uses ListAgents at filter-list |
| 151 | // scale ≤50). |
| 152 | func (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 | |
| 172 | type webhookOutput struct{ Body WebhookView } |
| 173 | type webhookCreateOutput struct{ Body CreateWebhookResponse } |
no test coverage detected