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

Function validateSafeOutputsSamples

pkg/workflow/samples_validation.go:105–125  ·  view source on GitHub ↗

validateSafeOutputsSamples validates every `samples` entry on every enabled safe-output handler against the corresponding MCP tool's inputSchema. Sample sidecar fields (e.g. `patch`) are stripped before validation. Returns the first error encountered; iteration order is deterministic (sorted by stru

(config *SafeOutputsConfig)

Source from the content-addressed store, hash-verified

103// the first error encountered; iteration order is deterministic (sorted by
104// struct field name) so error messages are stable.
105func validateSafeOutputsSamples(config *SafeOutputsConfig) error {
106 if config == nil {
107 return nil
108 }
109
110 fieldNames := sliceutil.SortedKeys(safeOutputFieldMapping)
111 samplesValidationLog.Printf("Validating safe-outputs samples across %d candidate fields", len(fieldNames))
112
113 for _, fieldName := range fieldNames {
114 toolName := safeOutputFieldMapping[fieldName]
115 base := extractBaseSafeOutputConfig(config, fieldName)
116 if base == nil || len(base.Samples) == 0 {
117 continue
118 }
119 samplesValidationLog.Printf("Validating %d sample(s) for field %q (tool %q)", len(base.Samples), fieldName, toolName)
120 if err := validateSamplesForTool(toolName, base.Samples); err != nil {
121 return err
122 }
123 }
124 return nil
125}
126
127// extractBaseSafeOutputConfig returns the embedded BaseSafeOutputConfig of the
128// non-nil safe-output config at SafeOutputsConfig.<fieldName>, or nil if the

Calls 4

SortedKeysFunction · 0.92
validateSamplesForToolFunction · 0.85
PrintfMethod · 0.45