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

Function parseRequiredBridgeJSONWithLabel

internal/cli/bridge.go:1158–1178  ·  view source on GitHub ↗
(raw string, label string)

Source from the content-addressed store, hash-verified

1156}
1157
1158func parseRequiredBridgeJSONWithLabel(raw string, label string) (*json.RawMessage, error) {
1159 trimmed := strings.TrimSpace(raw)
1160 trimmedLabel := strings.TrimSpace(label)
1161 if trimmedLabel == "" {
1162 trimmedLabel = "JSON payload"
1163 }
1164 if trimmed == "" {
1165 return nil, fmt.Errorf("cli: %s must be valid JSON; use null to clear", trimmedLabel)
1166 }
1167 var decoded any
1168 if err := json.Unmarshal([]byte(trimmed), &decoded); err != nil {
1169 return nil, fmt.Errorf("cli: %s must be valid JSON", trimmedLabel)
1170 }
1171 switch decoded.(type) {
1172 case nil, map[string]any:
1173 default:
1174 return nil, fmt.Errorf("cli: %s must be a JSON object or null", trimmedLabel)
1175 }
1176 value := json.RawMessage(trimmed)
1177 return &value, nil
1178}
1179
1180func bridgeRoutingPolicyLabel(policy bridgepkg.RoutingPolicy) string {
1181 dimensions := make([]string, 0, 3)

Callers 3

parseRequiredBridgeJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected