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

Function appendKnownFieldValidValuesHint

pkg/parser/schema_errors.go:353–370  ·  view source on GitHub ↗

appendKnownFieldValidValuesHint appends a "Valid values: …" hint, "Did you mean?" suggestions, and a documentation link to message when the jsonPath matches a well-known field and the message is an unknown-property error. It returns the message unchanged for unknown paths or non-additional-propertie

(message string, jsonPath string)

Source from the content-addressed store, hash-verified

351// It returns the message unchanged for unknown paths or non-additional-properties messages.
352// The second return value is true if a hint was actually appended to the message.
353func appendKnownFieldValidValuesHint(message string, jsonPath string) (string, bool) {
354 // Use truncated prefix "unknown propert" to match both singular ("Unknown property")
355 // and plural ("Unknown properties") forms produced by rewriteAdditionalPropertiesError.
356 if !strings.Contains(strings.ToLower(message), "unknown propert") {
357 return message, false
358 }
359 schemaErrorsLog.Printf("Appending known field hint for path: %s", jsonPath)
360
361 hint, scopes, docsURL, hintOK := knownFieldHintForPath(jsonPath)
362 if !hintOK {
363 return message, false
364 }
365
366 result := message + " (" + hint + ")"
367 result = appendKnownFieldSuggestions(result, message, scopes)
368 result = appendKnownFieldDocsURL(result, docsURL)
369 return result, true
370}
371
372func knownFieldHintForPath(jsonPath string) (string, []string, string, bool) {
373 if hint, ok := knownFieldValidValues[jsonPath]; ok {

Callers 2

Calls 5

knownFieldHintForPathFunction · 0.85
appendKnownFieldDocsURLFunction · 0.85
ToLowerMethod · 0.80
PrintfMethod · 0.45

Tested by 1