TranslateYAMLMessage translates a raw goccy/go-yaml parser message to a user-friendly description. It is the public entry point used by both the parser and workflow packages so that both code paths share a single translation table. The function performs a case-insensitive substring replacement of t
(message string)
| 79 | // pattern, leaving any surrounding text intact. This is safe for ASCII patterns because |
| 80 | // strings.ToLower preserves byte positions exactly for ASCII characters. |
| 81 | func TranslateYAMLMessage(message string) string { |
| 82 | lower := strings.ToLower(message) |
| 83 | for _, t := range yamlErrorTranslations { |
| 84 | if idx := strings.Index(lower, t.pattern); idx >= 0 { |
| 85 | yamlErrorLog.Printf("Translating YAML message pattern %q", t.pattern) |
| 86 | // Slice using idx from the lowercase string. Safe because all patterns are ASCII. |
| 87 | return message[:idx] + t.replacement + message[idx+len(t.pattern):] |
| 88 | } |
| 89 | } |
| 90 | return message |
| 91 | } |
| 92 | |
| 93 | // translateYAMLError translates cryptic goccy/go-yaml parser messages to user-friendly descriptions. |
| 94 | // It operates on the full yaml.FormatError() output, which includes a header line and source context: |