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

Function appendKnownFieldSuggestions

pkg/parser/schema_errors.go:397–415  ·  view source on GitHub ↗
(result, message string, scopes []string)

Source from the content-addressed store, hash-verified

395}
396
397func appendKnownFieldSuggestions(result, message string, scopes []string) string {
398 if len(scopes) == 0 {
399 return result
400 }
401 m := unknownPropertyPattern.FindStringSubmatch(message)
402 if len(m) != 2 {
403 return result
404 }
405
406 unknownProps := strings.Split(m[1], ", ")
407 unique := uniqueClosestScopeSuggestions(unknownProps, scopes)
408 if len(unique) == 1 {
409 return fmt.Sprintf("%s. Did you mean '%s'?", result, unique[0])
410 }
411 if len(unique) > 1 {
412 return fmt.Sprintf("%s. Did you mean: %s?", result, strings.Join(unique, ", "))
413 }
414 return result
415}
416
417func uniqueClosestScopeSuggestions(unknownProps []string, scopes []string) []string {
418 var allSuggestions []string

Callers 1

Calls 1

Tested by

no test coverage detected