{"record":{"id":"5924ba19dd761926","repo":"siyuan-note/siyuan","slug":"parse-attribute-view-context-filter-w","errorCode":null,"errorMessage":"parse attribute view context filter: %w","messagePattern":"parse attribute view context filter: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":5490,"sourceCode":"func GetAttributeViewContextFilter(attrView *av.AttributeView,\n\tblockID string) (ret *av.AttributeViewContextFilter, err error) {\n\tif nil == attrView || \"\" == blockID {\n\t\treturn\n\t}\n\tnode, _, err := getNodeByBlockID(nil, blockID)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\t// 普通内容块的数据库属性面板也会以内容块 ID 渲染属性视图，此时不存在块级上下文筛选。\n\tif nil == node || ast.NodeAttributeView != node.Type {\n\t\treturn nil, nil\n\t}\n\tif node.AttributeViewID != attrView.ID {\n\t\treturn nil, fmt.Errorf(\"block [%s] is not an instance of attribute view [%s]\", blockID, attrView.ID)\n\t}\n\tret, err = av.ParseAttributeViewContextFilter(node.IALAttr(av.NodeAttrContextFilter))\n\tif nil != err {\n\t\treturn nil, fmt.Errorf(\"parse attribute view context filter: %w\", err)\n\t}\n\treturn\n}\n\nfunc getAttributeViewInstanceNode(attrView *av.AttributeView,\n\tblockID string) (node *ast.Node, tree *parse.Tree, err error) {\n\tif nil == attrView || \"\" == blockID {\n\t\treturn nil, nil, av.ErrAttributeViewNotFound\n\t}\n\tnode, tree, err = getNodeByBlockID(nil, blockID)\n\tif nil != err {\n\t\treturn\n\t}\n\tif nil == node || nil == tree || ast.NodeAttributeView != node.Type || node.AttributeViewID != attrView.ID {\n\t\treturn nil, nil, fmt.Errorf(\"block [%s] is not an instance of attribute view [%s]\", blockID, attrView.ID)\n\t}\n\treturn\n}","sourceCodeStart":5472,"sourceCodeEnd":5508,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L5472-L5508","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const raw = node?.attributes?.[CONTEXT_FILTER_ATTR];\nif (raw) { try { JSON.parse(raw); } catch { /* corrupted; clear before read */ } }","typeGuard":null,"tryCatchPattern":"try {\n  return await api.getContextFilter(blockID, avID);\n} catch (e) {\n  if (/parse attribute view context filter/.test(e.message)) {\n    await api.clearContextFilter(blockID, avID); // drop malformed value\n    return null;\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["attribute-view","parse","filter","corruption"],"backgroundTag":"json-parse-error","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}