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

Function extractStringFromMap

pkg/workflow/config_helpers.go:112–122  ·  view source on GitHub ↗

extractStringFromMap is a generic helper that extracts and validates a string value from a map Returns the string value, or empty string if not present or invalid If log is provided, it will log the extracted value for debugging

(m map[string]any, key string, debugLog *logger.Logger)

Source from the content-addressed store, hash-verified

110// Returns the string value, or empty string if not present or invalid
111// If log is provided, it will log the extracted value for debugging
112func extractStringFromMap(m map[string]any, key string, debugLog *logger.Logger) string {
113 if value, exists := m[key]; exists {
114 if valueStr, ok := value.(string); ok {
115 if debugLog != nil {
116 debugLog.Printf("Parsed %s from config: %s", key, valueStr)
117 }
118 return valueStr
119 }
120 }
121 return ""
122}
123
124// parseTargetRepoWithValidation extracts the target-repo value from a config map and validates it.
125// Returns the target repository slug as a string, or empty string if not present or invalid.

Calls 1

PrintfMethod · 0.45

Tested by 3

TestExtractStringFromMapFunction · 0.68