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

Function stripAtPathPrefix

pkg/parser/schema_errors.go:238–255  ·  view source on GitHub ↗

stripAtPathPrefix removes "- at '/path': " or "at '/path': " prefixes from schema error lines and formats nested path references to be more readable. Examples: - "- at '/engine': value must be one of..." → "value must be one of..." - "- at '/permissions/deployments': value must be..." → "'deploymen

(line string)

Source from the content-addressed store, hash-verified

236// - "- at '/engine': value must be one of..." → "value must be one of..."
237// - "- at '/permissions/deployments': value must be..." → "'deployments': value must be..."
238func stripAtPathPrefix(line string) string {
239 match := atPathPattern.FindStringSubmatch(line)
240 if match == nil {
241 return line
242 }
243 path := match[1]
244 msg := match[2]
245
246 // For nested paths (e.g., /permissions/deployments), keep the last component
247 // so users know which sub-field has the error
248 if idx := strings.LastIndex(path, "/"); idx > 0 {
249 subField := path[idx+1:]
250 return fmt.Sprintf("'%s': %s", subField, msg)
251 }
252
253 // For top-level field errors, just return the constraint message
254 return msg
255}
256
257// findFrontmatterBounds finds the start and end indices of frontmatter in file lines
258// Returns: startIdx (-1 if not found), endIdx (-1 if not found), frontmatterContent

Callers 3

TestStripAtPathPrefixFunction · 0.85
cleanOneOfMessageFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStripAtPathPrefixFunction · 0.68