validateAWFConfigJSON validates the provided AWF config JSON string against the embedded AWF config schema. Returns nil if validation passes.
(configJSON string)
| 107 | // validateAWFConfigJSON validates the provided AWF config JSON string against the |
| 108 | // embedded AWF config schema. Returns nil if validation passes. |
| 109 | func validateAWFConfigJSON(configJSON string) error { |
| 110 | schema, err := getCompiledAWFConfigSchema() |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | var doc any |
| 115 | if err := json.Unmarshal([]byte(configJSON), &doc); err != nil { |
| 116 | return fmt.Errorf("failed to parse AWF config JSON: %w", err) |
| 117 | } |
| 118 | normalizeTemplatableModelFallbackEnabled(doc) |
| 119 | if err := schema.Validate(doc); err != nil { |
| 120 | return fmt.Errorf("AWF config schema validation failed: %w", err) |
| 121 | } |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | // normalizeTemplatableModelFallbackEnabled adjusts a generated AWF config document |
| 126 | // for compile-time schema validation by coercing modelFallback.enabled GitHub Actions |