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

Function formatJSONSchemaValidationWithLocation

pkg/parser/schema_compiler.go:405–427  ·  view source on GitHub ↗
(
	jsonPaths []JSONPathInfo,
	schemaJSON, filePath string,
	ctx frontmatterContextData,
)

Source from the content-addressed store, hash-verified

403}
404
405func formatJSONSchemaValidationWithLocation(
406 jsonPaths []JSONPathInfo,
407 schemaJSON, filePath string,
408 ctx frontmatterContextData,
409) error {
410 if len(jsonPaths) == 0 || ctx.frontmatterContent == "" {
411 return nil
412 }
413
414 detailLines := make([]string, 0, len(jsonPaths))
415 for _, pathInfo := range jsonPaths {
416 detailLines = append(detailLines, formatSchemaFailureDetail(pathInfo, schemaJSON, ctx.frontmatterContent, ctx.frontmatterStart))
417 }
418
419 location := LocateJSONPathForPathInfo(ctx.frontmatterContent, jsonPaths[0])
420 if !location.Found {
421 return nil
422 }
423 adjustedLine := location.Line + ctx.frontmatterStart - 1
424 contextLines := buildAdjustedContextLines(ctx, adjustedLine)
425 message := formatSchemaDetailMessage(detailLines)
426 return formatCompilerErrorWithLocation(filePath, adjustedLine, location.Column, message, contextLines)
427}
428
429func buildAdjustedContextLines(ctx frontmatterContextData, adjustedLine int) []string {
430 if len(ctx.allLines) == 0 {

Callers 1

Tested by

no test coverage detected