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

Function NormalizeAndValidateLabelList

internal/agent/api.go:1485–1503  ·  view source on GitHub ↗

NormalizeAndValidateLabelList runs each entry through normalizeAndValidateLabel, dedups within the slice, and rejects if the slice is empty after trimming or exceeds the per-op cap. The `op` argument is used only to shape the error message.

(raw []string, op string)

Source from the content-addressed store, hash-verified

1483// the slice is empty after trimming or exceeds the per-op cap. The
1484// `op` argument is used only to shape the error message.
1485func NormalizeAndValidateLabelList(raw []string, op string) ([]string, error) {
1486 if len(raw) > MaxLabelsPerOp {
1487 return nil, fmt.Errorf("%s_labels exceeds per-request cap of %d", op, MaxLabelsPerOp)
1488 }
1489 seen := map[string]struct{}{}
1490 out := make([]string, 0, len(raw))
1491 for _, r := range raw {
1492 l, err := normalizeAndValidateLabel(r, false)
1493 if err != nil {
1494 return nil, err
1495 }
1496 if _, dup := seen[l]; dup {
1497 continue
1498 }
1499 seen[l] = struct{}{}
1500 out = append(out, l)
1501 }
1502 return out, nil
1503}
1504
1505// validateRecipients ensures every entry in the joined To/CC/BCC slices
1506// is a syntactically valid RFC 5322 address. We use net/mail.ParseAddress

Callers 1

handleUpdateMessageMethod · 0.92

Calls 2

makeFunction · 0.85

Tested by

no test coverage detected