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)
| 888 | // Any other shape returns an empty slice — schema validation rejects those |
| 889 | // shapes upstream and we keep this parser strict to match. |
| 890 | func 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 |
no outgoing calls
no test coverage detected