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

Function parseOptionalStringSliceField

pkg/workflow/role_checks.go:186–213  ·  view source on GitHub ↗

parseOptionalStringSliceField parses string-list fields that accept either a single string or an array. Empty strings are filtered out.

(value any, fieldName string)

Source from the content-addressed store, hash-verified

184// parseOptionalStringSliceField parses string-list fields that accept either
185// a single string or an array. Empty strings are filtered out.
186func parseOptionalStringSliceField(value any, fieldName string) []string {
187 if singleValue, ok := value.(string); ok {
188 if singleValue == "" {
189 return nil
190 }
191 roleLog.Printf("Extracted single %s: %s", fieldName, singleValue)
192 return []string{singleValue}
193 }
194
195 values := parseStringSliceAny(value, roleLog)
196 if len(values) == 0 {
197 roleLog.Printf("No valid %s found or unsupported type: %T", fieldName, value)
198 return nil
199 }
200
201 result := make([]string, 0, len(values))
202 for _, item := range values {
203 if item != "" {
204 result = append(result, item)
205 }
206 }
207 if len(result) == 0 {
208 return nil
209 }
210
211 roleLog.Printf("Extracted %d %s: %v", len(result), fieldName, result)
212 return result
213}
214
215// extractRateLimitConfig extracts the user-rate-limit config from frontmatter.
216func (c *Compiler) extractRateLimitConfig(frontmatter map[string]any) *RateLimitConfig {

Callers 4

extractLabelNamesMethod · 0.85
parseBotsValueFunction · 0.85
extractSkipFieldFunction · 0.85

Calls 2

parseStringSliceAnyFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected