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

Function parseConfigScaffold

pkg/workflow/config_helpers.go:233–248  ·  view source on GitHub ↗

parseConfigScaffold is the generic parser scaffold for safe-output handler config parsers. It implements the common four-step pattern shared across safe-output handlers: 1. Key existence check – returns nil immediately if the key is absent in outputMap 2. Entry log: "Parsing configuration" 3.

(
	outputMap map[string]any,
	key string,
	debugLog *logger.Logger,
	onError func(err error) *T,
)

Source from the content-addressed store, hash-verified

231// return nil
232// })
233func parseConfigScaffold[T any](
234 outputMap map[string]any,
235 key string,
236 debugLog *logger.Logger,
237 onError func(err error) *T,
238) *T {
239 if _, exists := outputMap[key]; !exists {
240 return nil
241 }
242 debugLog.Printf("Parsing %s configuration", key)
243 var config T
244 if err := unmarshalConfig(outputMap, key, &config, debugLog); err != nil {
245 return onError(err)
246 }
247 return &config
248}

Calls 3

unmarshalConfigFunction · 0.85
onErrorFunction · 0.50
PrintfMethod · 0.45