{"record":{"id":"055de086a32d7980","repo":"siyuan-note/siyuan","slug":"filter-nesting-depth-exceeds-the-maximum-allowed","errorCode":null,"errorMessage":"filter nesting depth exceeds the maximum allowed","messagePattern":"filter nesting depth exceeds the maximum allowed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1302,"sourceCode":"\t}\n\treturn\n}\n\nfunc GetAttributeViewI18n(key string) string {\n\treturn util.AttrViewLangs[util.Lang][key].(string)\n}\n\nvar (\n\tErrAttributeViewNotFound  = errors.New(\"attribute view not found\")\n\tErrInvalidAttributeViewID = errors.New(\"invalid attribute view id\")\n\tErrInvalidBoxID           = errors.New(\"invalid box id\")\n\tErrViewNotFound           = errors.New(\"view not found\")\n\tErrKeyNotFound            = errors.New(\"key not found\")\n\tErrItemNotFound           = errors.New(\"item not found\")\n\tErrWrongLayoutType        = errors.New(\"wrong layout type\")\n\tErrInvalidColumnAlign     = errors.New(\"invalid column align\")\n\tErrSpecTooNew             = errors.New(\"attribute view spec is too new\")\n\tErrFilterTooDeep          = errors.New(\"filter nesting depth exceeds the maximum allowed\")\n)\n\nconst (\n\tNodeAttrNameAvs        = \"custom-avs\"                 // 用于标记块所属的属性视图，逗号分隔 av id\n\tNodeAttrView           = \"custom-sy-av-view\"          // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443\n\tNodeAttrVisibleViewIDs = \"custom-sy-av-visible-views\" // 用于标记数据库块显示的视图 ID，逗号分隔\n\tNodeAttrViewStaticText = \"custom-sy-av-s-text\"        // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049\n\n\tNodeAttrViewNames = \"av-names\" // 用于临时标记块所属的属性视图名称，空格分隔\n)\n","sourceCodeStart":1284,"sourceCodeEnd":1313,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/av.go#L1284-L1313","documentation":"Sentinel ErrFilterTooDeep. Returned by validateFilterNodeDepth (av/filter.go:169) when a group filter (AND/OR combination) is nested deeper than MaxFilterNestingDepth (3). ValidateFilterDepth walks each top-level filter and recurses into group children; exceeding depth 3 aborts to prevent pathological/expensive filter trees.","triggerScenarios":"Submitting a setfilter operation (or saving a view) whose filter tree nests groups more than 3 levels: e.g. an AND group containing an OR group containing an AND group containing another group. The client constructed a deeply nested combination.","commonSituations":"A UI that lets users nest filter groups arbitrarily without a depth cap; a plugin importing an external query as a deep filter tree; programmatic construction that wraps every predicate in its own group.","solutions":["Flatten the filter tree to at most 3 levels of grouping before submitting.","Combine sibling predicates under one group instead of wrapping each predicate in its own group.","Add a client-side depth check mirroring MaxFilterNestingDepth (3) to reject deep trees before the round trip."],"exampleFix":"// before\n// deeply nested: AND( OR( AND( OR( p1, p2 ) ) ) )  -> depth 4 -> filter too deep\nfilter := &av.ViewFilter{Combination: \"and\", Filters: []*av.ViewFilter{\n    {Combination: \"or\", Filters: []*av.ViewFilter{\n        {Combination: \"and\", Filters: []*av.ViewFilter{\n            {Combination: \"or\", Filters: []*av.ViewFilter{p1, p2}},\n        }},\n    }},\n}}\n\n// after: flatten to <= 3 levels\nfilter := &av.ViewFilter{Combination: \"and\", Filters: []*av.ViewFilter{\n    {Combination: \"or\", Filters: []*av.ViewFilter{p1, p2}},\n}}","handlingStrategy":"validation","validationCode":"// Enforce the depth cap client-side before submitting\nconst MAX_DEPTH = 3\nfunc checkDepth(f *av.ViewFilter, depth int) error {\n    if f == nil || !f.IsGroup() { return nil }\n    if depth > MAX_DEPTH { return errors.New(\"filter too deep\") }\n    for _, c := range f.Filters { if e := checkDepth(c, depth+1); e != nil { return e } }\n    return nil\n}\nfor _, f := range filters { if e := checkDepth(f, 1); e != nil { return e } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap filter group nesting at 3 levels in the UI.","Flatten sibling predicates into one group instead of wrapping each.","Reject deep trees before the round trip to avoid a server error."],"tags":["attribute-view","filter","validation","depth-limit","api"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}