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

Method validateEngineInlineDefinition

pkg/workflow/engine_validation.go:230–262  ·  view source on GitHub ↗

validateEngineInlineDefinition validates an inline engine definition parsed from engine.runtime + optional engine.provider in the workflow frontmatter. Returns an error if: - The required runtime.id field is missing - The runtime.id does not match a known runtime adapter

(config *EngineConfig)

Source from the content-addressed store, hash-verified

228// - The required runtime.id field is missing
229// - The runtime.id does not match a known runtime adapter
230func (c *Compiler) validateEngineInlineDefinition(config *EngineConfig) error {
231 if !config.IsInlineDefinition {
232 return nil
233 }
234
235 engineValidationLog.Printf("Validating inline engine definition: runtimeID=%s", config.ID)
236
237 if config.ID == "" {
238 return fmt.Errorf("inline engine definition is missing required 'runtime.id' field.\n\nExample:\nengine:\n runtime:\n id: codex\n\nSee: %s", constants.DocsEnginesURL)
239 }
240
241 // Validate that runtime.id maps to a known runtime adapter.
242 if !c.engineRegistry.IsValidEngine(config.ID) {
243 // Try prefix match for backward compatibility (e.g. "codex-experimental")
244 if matched, err := c.engineRegistry.GetEngineByPrefix(config.ID); err == nil {
245 engineValidationLog.Printf("Inline engine runtime.id %q matched via prefix to runtime %q", config.ID, matched.GetID())
246 } else {
247 validEngines := c.engineRegistry.GetSupportedEngines()
248 suggestions := parser.FindClosestMatches(config.ID, validEngines, 1)
249 enginesStr := strings.Join(validEngines, ", ")
250
251 errMsg := fmt.Sprintf("inline engine definition references unknown runtime.id: %s. Known runtime IDs are: %s.\n\nExample:\nengine:\n runtime:\n id: codex\n\nSee: %s",
252 config.ID, enginesStr, constants.DocsEnginesURL)
253 if len(suggestions) > 0 {
254 errMsg = fmt.Sprintf("inline engine definition references unknown runtime.id: %s. Known runtime IDs are: %s.\n\nDid you mean: %s?\n\nExample:\nengine:\n runtime:\n id: codex\n\nSee: %s",
255 config.ID, enginesStr, suggestions[0], constants.DocsEnginesURL)
256 }
257 return errors.New(errMsg)
258 }
259 }
260
261 return nil
262}
263
264// registerInlineEngineDefinition registers an inline engine definition in the session
265// catalog. If the runtime ID already exists in the catalog (e.g. a built-in), the

Calls 7

FindClosestMatchesFunction · 0.92
IsValidEngineMethod · 0.80
GetEngineByPrefixMethod · 0.80
GetSupportedEnginesMethod · 0.80
GetIDMethod · 0.65
PrintfMethod · 0.45
ErrorfMethod · 0.45