siyuan-note/siyuan · error

ErrFilterTooDeep

ErrFilterTooDeep

Error message

filter nesting depth exceeds the maximum allowed

What it means

ErrFilterTooDeep is returned when a database filter tree nests more than MaxFilterNestingDepth (3) levels of filter groups. The kernel validates filter nesting depth (filter.go:220) to protect both the UI and recursive evaluation from pathological inputs.

Source

Thrown at kernel/av/av.go:1349

	return
}

func GetAttributeViewI18n(key string) string {
	return util.AttrViewLangs[util.Lang][key].(string)
}

var (
	ErrAttributeViewNotFound  = errors.New("attribute view not found")
	ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
	ErrInvalidBoxID           = errors.New("invalid box id")
	ErrViewNotFound           = errors.New("view not found")
	ErrKeyNotFound            = errors.New("key not found")
	ErrItemNotFound           = errors.New("item not found")
	ErrWrongLayoutType        = errors.New("wrong layout type")
	ErrInvalidColumnAlign     = errors.New("invalid column align")
	ErrSpecTooNew             = errors.New("attribute view spec is too new")
	ErrRichTextSpecMismatch   = errors.New("attribute view rich text requires storage spec 9")
	ErrFilterTooDeep          = errors.New("filter nesting depth exceeds the maximum allowed")
)

const (
	NodeAttrNameAvs        = "custom-avs"                  // 用于标记块所属的属性视图,逗号分隔 av id
	NodeAttrView           = "custom-sy-av-view"           // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
	NodeAttrVisibleViewIDs = "custom-sy-av-visible-views"  // 用于标记数据库块显示的视图 ID,逗号分隔
	NodeAttrContextFilter  = "custom-sy-av-context-filter" // 用于保存数据库块独有的上下文筛选配置
	NodeAttrViewStaticText = "custom-sy-av-s-text"         // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049

	NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔
)

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Flatten the filter tree to at most 3 levels of nesting (merge same-operator groups, apply De Morgan transforms to reduce depth).
  2. Split the query into multiple views or multiple saved filters instead of one deep tree.
  3. If writing a generator, cap recursion depth at MaxFilterNestingDepth (av.MaxFilterNestingDepth == 3) before emitting groups.
  4. Log which filter path is over depth (kernel already logs depth vs max) and inspect the view JSON at custom-sy-av filter nodes.

Example fix

// before
filter := {group: {group: {group: {group: {...}}}}} // depth 4

// after
// flatten: same-operator children hoisted one level, depth <= av.MaxFilterNestingDepth (3)
filter := {group: {group: {group: {...}}}}
Defensive patterns

Strategy: validation

Validate before calling

func filterDepthOK(f *av.Filter) bool { return maxDepth(f) <= av.MaxFilterNestingDepth }

Try / catch

if err := applyFilters(view); errors.Is(err, av.ErrFilterTooDeep) {
	// flatten filter groups and retry
}

Prevention

When it happens

Trigger: Saving or evaluating an attribute view filter JSON whose group nesting exceeds 3 levels; validateFilterNodeDepth during view deserialization or filter application; programmatically constructing deeply nested And/Or filter groups via the API or by editing .av JSON.

Common situations: A plugin or script generating filter expressions recursively without a depth cap; a sync/merge producing nested filter groups from two edited views; hand-edited .av JSON copied from another tool.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/5b9bf51093897fef. Report an issue: GitHub.