siyuan-note/siyuan · error
parse attribute view context filter
Error message
parse attribute view context filter: %w
What it means
The stored context-filter configuration of a database block failed to parse (av.ParseAttributeViewContextFilter returned an error) when the read path tried to decode the node's IAL filter attribute. The filter value persisted on the block is malformed or of an unsupported format version, so the read fails and wraps the underlying parse error with this message.
Solutions
- Inspect the block's IAL for the context-filter attribute and fix or remove the malformed value
- Clear the context filter via the API (SetAttributeViewContextFilter with empty keyID) to rewrite a valid value, or delete the attribute and reconfigure the filter
- Restore the block from history/sync if the corruption came from a bad replay
- Ensure kernel and client versions agree on the filter format
Defensive patterns
Strategy: try-catch
Validate before calling
const raw = node?.attributes?.[CONTEXT_FILTER_ATTR];
if (raw) { try { JSON.parse(raw); } catch { /* corrupted; clear before read */ } } Try / catch
try {
return await api.getContextFilter(blockID, avID);
} catch (e) {
if (/parse attribute view context filter/.test(e.message)) {
await api.clearContextFilter(blockID, avID); // drop malformed value
return null;
}
throw e;
} Prevention
- Do not hand-edit .sy files or block custom attributes
- Always set filters through the API so they are serialized in the current format
- Keep kernel versions consistent across clients sharing a workspace
- Back up documents before external tooling touches IAL attributes
When it happens
Trigger: Reading GetAttributeViewContextFilter for a block whose node carries a context-filter IAL attribute (av.NodeAttrContextFilter) that does not unmarshal into the expected AttributeViewContextFilter struct — e.g. corrupted JSON, hand-edited .sy file, or a filter written by a newer/older format version.
Common situations: Manual editing or external tooling modified the block's custom attributes; a partial write or interrupted sync left truncated JSON; forward/backward format incompatibility between kernel versions.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- database back relation value is invalid
- ErrFilterTooDeep
- filter group requires and/or combination
- filter nesting depth exceeds the maximum allowed
- invalid attribute view context filter
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/5924ba19dd761926.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view.go:5490
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 9f775e8a12)