MCPcopy Create free account
hub / github.com/github/gh-aw / parseSamplesValue

Function parseSamplesValue

pkg/workflow/safe_outputs_config.go:890–911  ·  view source on GitHub ↗

parseSamplesValue normalizes a `samples` frontmatter value into a list of objects. Accepted shapes: - YAML list of mappings: returned as-is - single YAML mapping: wrapped into a one-element list Any other shape returns an empty slice — schema validation rejects those shapes upstream and we keep thi

(samples any)

Source from the content-addressed store, hash-verified

888// Any other shape returns an empty slice — schema validation rejects those
889// shapes upstream and we keep this parser strict to match.
890func parseSamplesValue(samples any) []map[string]any {
891 switch v := samples.(type) {
892 case []any:
893 out := make([]map[string]any, 0, len(v))
894 for _, item := range v {
895 if m, ok := item.(map[string]any); ok {
896 out = append(out, m)
897 } else if mStr, ok := item.(map[string]string); ok {
898 converted := make(map[string]any, len(mStr))
899 for k, s := range mStr {
900 converted[k] = s
901 }
902 out = append(out, converted)
903 }
904 }
905 return out
906 case map[string]any:
907 return []map[string]any{v}
908 default:
909 return nil
910 }
911}
912
913// SafeOutputStepConfig holds configuration for building a single safe output step
914// within the consolidated safe-outputs job

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected