MCPcopy Create free account
hub / github.com/modelcontextprotocol/registry / addDetailedErrors

Function addDetailedErrors

internal/validators/schema.go:316–350  ·  view source on GitHub ↗

addDetailedErrors recursively processes detailed validation errors

(result *ValidationResult, detailed jsonschema.Detailed, schema map[string]any)

Source from the content-addressed store, hash-verified

314
315// addDetailedErrors recursively processes detailed validation errors
316func addDetailedErrors(result *ValidationResult, detailed jsonschema.Detailed, schema map[string]any) {
317 // Only process errors that have specific field paths and meaningful messages
318 if detailed.InstanceLocation != "" && detailed.Error != "" {
319 // Convert JSON Pointer format to bracket notation to match semantic validation format
320 path := ConvertJSONPointerToBracketNotation(detailed.InstanceLocation)
321
322 // Clean up the error message
323 message := detailed.Error
324
325 // Make messages more user-friendly
326 if strings.Contains(message, "missing properties:") {
327 message = strings.ReplaceAll(message, "missing properties:", "missing required fields:")
328 }
329 if strings.Contains(message, "is not valid") {
330 message = strings.ReplaceAll(message, "is not valid", "has invalid format")
331 }
332
333 // Build the full resolved reference path
334 reference := buildResolvedReference(detailed.KeywordLocation, detailed.AbsoluteKeywordLocation, schema)
335
336 issue := NewValidationIssue(
337 ValidationIssueTypeSchema,
338 path,
339 message,
340 ValidationIssueSeverityError,
341 reference, // cleaned schema rule path for deterministic mapping
342 )
343 result.AddIssue(issue)
344 }
345
346 // Process nested errors
347 for _, nested := range detailed.Errors {
348 addDetailedErrors(result, nested, schema)
349 }
350}
351
352// buildResolvedReference extracts the resolved reference path by resolving $ref segments
353func buildResolvedReference(keywordLocation, absoluteKeywordLocation string, schema map[string]any) string {

Callers 1

addValidationErrorFunction · 0.85

Calls 4

buildResolvedReferenceFunction · 0.85
NewValidationIssueFunction · 0.85
AddIssueMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…