siyuan-note/siyuan · error
parse attribute view context filter: %w
Error message
parse attribute view context filter: %w
What it means
Wraps an error from av.ParseAttributeViewContextFilter when the attribute view block's stored context-filter IAL value fails to parse into a valid AttributeViewContextFilter. The underlying error is preserved with %w; the wrapper adds the phase where parsing failed.
Source
Thrown at kernel/model/attribute_view.go:5465
func GetAttributeViewContextFilter(attrView *av.AttributeView,
blockID string) (ret *av.AttributeViewContextFilter, err error) {
if nil == attrView || "" == blockID {
return
}
node, _, err := getNodeByBlockID(nil, blockID)
if nil != err {
return nil, err
}
// 普通内容块的数据库属性面板也会以内容块 ID 渲染属性视图,此时不存在块级上下文筛选。
if nil == node || ast.NodeAttributeView != node.Type {
return nil, nil
}
if node.AttributeViewID != attrView.ID {
return nil, fmt.Errorf("block [%s] is not an instance of attribute view [%s]", blockID, attrView.ID)
}
ret, err = av.ParseAttributeViewContextFilter(node.IALAttr(av.NodeAttrContextFilter))
if nil != err {
return nil, fmt.Errorf("parse attribute view context filter: %w", err)
}
return
}
func getAttributeViewInstanceNode(attrView *av.AttributeView,
blockID string) (node *ast.Node, tree *parse.Tree, err error) {
if nil == attrView || "" == blockID {
return nil, nil, av.ErrAttributeViewNotFound
}
node, tree, err = getNodeByBlockID(nil, blockID)
if nil != err {
return
}
if nil == node || nil == tree || ast.NodeAttributeView != node.Type || node.AttributeViewID != attrView.ID {
return nil, nil, fmt.Errorf("block [%s] is not an instance of attribute view [%s]", blockID, attrView.ID)
}
return
}View on GitHub (pinned to 8641553a1f)
Solutions
- Clear the block's context-filter IAL attribute and reconfigure the filter in the UI
- Inspect the IAL value and fix it to match the current AttributeViewContextFilter JSON schema
- Update to the latest SiYuan version so the current filter schema is used for parsing
Defensive patterns
Strategy: try-catch
Validate before calling
const raw = node?.ial?.["custom-context-filter"]; if (raw) JSON.parse(raw); // throws early if malformed
Try / catch
try { const f = await getAvContextFilter(blockID, avID); } catch (e) { if (String(e).includes("context filter")) await clearAndReconfigureFilter(blockID); else throw e; } Prevention
- Do not hand-edit context-filter IAL values
- Upgrade to the latest version before reading filters written by newer builds
- Reconfigure filters after undo/redo anomalies
When it happens
Trigger: Reading the context filter of a database block whose custom IAL attribute (the context-filter key) contains malformed, truncated, or schema-invalid JSON — e.g. written by an older version or corrupted during sync/undo replay.
Common situations: Undo/redo replay restored an IAL written before a filter-schema change; manual IAL editing produced invalid JSON; a sync conflict merged partial filter data.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
Related errors
- ErrInvalidAttributeViewContextFilter
- ErrAttributeViewContextNotBound
- validate attribute view context filter target: %w
- attribute view not found
- invalid attribute view id
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/5924ba19dd761926.
Report an issue: GitHub.