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

Method parseAssignToUserConfig

pkg/workflow/assign_to_user.go:19–60  ·  view source on GitHub ↗

parseAssignToUserConfig handles assign-to-user configuration

(outputMap map[string]any)

Source from the content-addressed store, hash-verified

17
18// parseAssignToUserConfig handles assign-to-user configuration
19func (c *Compiler) parseAssignToUserConfig(outputMap map[string]any) *AssignToUserConfig {
20 // Check key existence first so we can preprocess templatable fields before YAML unmarshaling
21 if _, exists := outputMap["assign-to-user"]; !exists {
22 return nil
23 }
24
25 // Get config data for pre-processing before YAML unmarshaling
26 configData, _ := outputMap["assign-to-user"].(map[string]any)
27
28 // Pre-process templatable bool fields
29 if err := preprocessBoolFieldAsString(configData, "unassign-first", assignToUserLog); err != nil {
30 assignToUserLog.Printf("Invalid unassign-first value: %v", err)
31 return nil
32 }
33
34 // Pre-process templatable int fields
35 if err := preprocessIntFieldAsString(configData, "max", assignToUserLog); err != nil {
36 assignToUserLog.Printf("Invalid max value: %v", err)
37 return nil
38 }
39
40 config := parseConfigScaffold(outputMap, "assign-to-user", assignToUserLog, func(err error) *AssignToUserConfig {
41 assignToUserLog.Printf("Failed to unmarshal config: %v", err)
42 // For backward compatibility, use defaults
43 assignToUserLog.Print("Using default configuration")
44 return &AssignToUserConfig{
45 BaseSafeOutputConfig: BaseSafeOutputConfig{Max: defaultIntStr(1)},
46 }
47 })
48 if config == nil {
49 return nil
50 }
51
52 // Set default max if not specified
53 if config.Max == nil {
54 config.Max = defaultIntStr(1)
55 }
56
57 assignToUserLog.Printf("Parsed configuration: allowed_count=%d, target=%s", len(config.Allowed), config.Target)
58
59 return config
60}

Callers 1

Calls 6

parseConfigScaffoldFunction · 0.85
defaultIntStrFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected