fix: error handling in extended schema
This commit is contained in:
@@ -86,20 +86,17 @@ func (v *schemav2Validator) validateExtendedSchemas(ctx context.Context, body in
|
|||||||
log.Debugf(ctx, "Extended Schema config: ttl=%v, timeout=%v, allowedDomains=%v",
|
log.Debugf(ctx, "Extended Schema config: ttl=%v, timeout=%v, allowedDomains=%v",
|
||||||
ttl, timeout, allowedDomains)
|
ttl, timeout, allowedDomains)
|
||||||
|
|
||||||
// Validate each object and collect errors
|
// Validate each object
|
||||||
var errors []string
|
|
||||||
for _, obj := range objects {
|
for _, obj := range objects {
|
||||||
log.Debugf(ctx, "Validating object at path: %s, @context: %s, @type: %s",
|
log.Debugf(ctx, "Validating object at path: %s, @context: %s, @type: %s",
|
||||||
obj.Path, obj.Context, obj.Type)
|
obj.Path, obj.Context, obj.Type)
|
||||||
|
|
||||||
if err := v.schemaCache.validateReferencedObject(ctx, obj, ttl, timeout, allowedDomains); err != nil {
|
if err := v.schemaCache.validateReferencedObject(ctx, obj, ttl, timeout, allowedDomains); err != nil {
|
||||||
errors = append(errors, err.Error())
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errors) > 0 {
|
return nil
|
||||||
return fmt.Errorf("validation errors:\n - %s", strings.Join(errors, "\n - "))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user