siyuan-note/siyuan · warning
validation exceeded %s
Error message
validation exceeded %s
What it means
Thrown by validateResolved when schema.Validate(value) does not return within toolValidationTime (2s) after acquiring a slot. Unlike error 365 (could not start), this means validation started but the jsonschema evaluator is taking too long — typically due to catastrophic regex backtracking, exponential $ref combinatorics, or an enormous value against a complex schema.
Source
Thrown at kernel/mcp/tools/validation.go:186
return ctx.Err()
case <-timer.C:
return fmt.Errorf("validation did not start within %s", toolValidationTime)
}
result := make(chan error, 1)
go func() {
err := schema.Validate(value)
<-validationSlots
result <- err
}()
select {
case err := <-result:
return err
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
return fmt.Errorf("validation exceeded %s", toolValidationTime)
}
}
func validateJSONComplexity(value any, maxDepth, maxNodes int) error {
nodes := 0
var walk func(any, int) error
walk = func(current any, depth int) error {
if depth > maxDepth {
return fmt.Errorf("JSON depth exceeds %d", maxDepth)
}
nodes++
if nodes > maxNodes {
return fmt.Errorf("JSON node count exceeds %d", maxNodes)
}
switch typed := current.(type) {
case map[string]any:
for _, child := range typed {
if err := walk(child, depth+1); err != nil {View on GitHub (pinned to 251596fc0d)
Solutions
- Simplify the schema: replace risky regexes with anchored, linear patterns; flatten or bound recursive $ref definitions; prune redundant anyOf/oneOf branches.
- Reduce the value size (see error 364) so validation has less work.
- Pre-validate expensive constraints incrementally or cache compiled (Resolved) schemas.
- If unavoidable, surface a clear user-facing message and degrade gracefully rather than retrying the same slow validation.
Example fix
// before: regex vulnerable to catastrophic backtracking
{"pattern": "^(a+)+$"}
// after: anchored, linear pattern
{"pattern": "^a*$"} Defensive patterns
Strategy: validation
Try / catch
err := validator.ValidateInputContext(ctx, args)
if err != nil && strings.Contains(err.Error(), "validation exceeded") {
// schema is too slow against this value: simplify schema or shrink value
} Prevention
- Avoid regexes susceptible to catastrophic backtracking in schemas.
- Flatten recursive $ref definitions and prune redundant anyOf/oneOf branches.
- Profile schema.Validate on representative inputs during development.
When it happens
Trigger: A single schema.Validate(value) call runs longer than 2s. Common with patterns vulnerable to ReDoS, deeply recursive schemas, or validating a multi-megabyte value against a schema with many constraints.
Common situations: A tool schema includes a user-supplied regex that backtracks catastrophically; a schema uses recursive $ref structures that explode against nested data; validating a near-8 MiB value against a schema with many anyOf/oneOf branches.
Related errors
- validation did not start within %s
- tools/list returned an empty response
- tools/list repeated cursor %q
- unsupported server type: %s
- command is required for stdio server
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/343d1745488164f9.
Report an issue: GitHub.