MCPcopy Create free account
hub / github.com/compozy/agh / decodeCapabilityEnvelopeBody

Function decodeCapabilityEnvelopeBody

internal/network/validate.go:521–533  ·  view source on GitHub ↗
(raw json.RawMessage)

Source from the content-addressed store, hash-verified

519}
520
521func decodeCapabilityEnvelopeBody(raw json.RawMessage) (Body, error) {
522 object, err := validateJSONObject("body", raw)
523 if err != nil {
524 return nil, err
525 }
526 if _, ok := object["capability"]; !ok {
527 return nil, fmt.Errorf(
528 "%w: capability body must wrap artifact fields inside \"capability\", e.g. {\"capability\":{...}}",
529 ErrInvalidBody,
530 )
531 }
532 return decodeNormalizedBody(raw, "capability", normalizeAndValidateCapabilityBody)
533}
534
535func decodeNormalizedBody[T Body](raw json.RawMessage, label string, normalize func(*T) error) (Body, error) {
536 var body T

Callers

nothing calls this directly

Calls 2

decodeNormalizedBodyFunction · 0.85
validateJSONObjectFunction · 0.70

Tested by

no test coverage detected