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

Function TranslateYAMLMessage

pkg/parser/yaml_error.go:81–91  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

79// pattern, leaving any surrounding text intact. This is safe for ASCII patterns because
80// strings.ToLower preserves byte positions exactly for ASCII characters.
81func 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:

Callers 4

TestTranslateYAMLMessageFunction · 0.92
TestTranslateYAMLMessageFunction · 0.85
translateYAMLErrorFunction · 0.85

Calls 2

ToLowerMethod · 0.80
PrintfMethod · 0.45

Tested by 2

TestTranslateYAMLMessageFunction · 0.74
TestTranslateYAMLMessageFunction · 0.68