siyuan-note/siyuan · error
invalid attribute view context filter
Error message
invalid attribute view context filter
What it means
ErrInvalidAttributeViewContextFilter is the sentinel error for a malformed attribute view context filter — the per-physical-database-block filter configuration. ParseAttributeViewContextFilter returns it (wrapped with decode details) when the JSON cannot be decoded, and Validate returns it when the decoded filter has the wrong spec version or an empty KeyID.
Solutions
- Check the wrapped %v detail when it comes from decoding — fix the JSON syntax
- Ensure the filter JSON has "spec": 1 matching AttributeViewContextFilterSpec
- Populate keyID with the target database's key identifier; regenerate the filter blob if corrupt
Example fix
// before
{"spec":2,"keyID":""}
// after
{"spec":1,"keyID":"20240101120000-abcdefg"} Defensive patterns
Strategy: validation
Validate before calling
var f map[string]interface{}
if err := json.Unmarshal(raw, &f); err != nil { return err }
if f["spec"] != float64(av.AttributeViewContextFilterSpec) { return errors.New("bad spec") }
keyID, _ := f["keyID"].(string)
if strings.TrimSpace(keyID) == "" { return errors.New("empty keyID") } Try / catch
filter, err := av.ParseAttributeViewContextFilter(raw)
if err != nil {
if errors.Is(err, av.ErrInvalidAttributeViewContextFilter) { regenerateFilter(block) }
} Prevention
- Always emit "spec": 1 exactly as AttributeViewContextFilterSpec
- Never persist a filter with an empty keyID
- Regenerate filter blobs from the source database instead of hand-editing JSON
When it happens
Trigger: Calling ParseAttributeViewContextFilter with JSON that fails to decode (line 66), or with JSON whose spec != AttributeViewContextFilterSpec (currently 1) or whose keyID is blank/whitespace (line 75).
Common situations: Filter blobs written by older/newer kernel versions with a different spec number; hand-crafted or truncated JSON stored on the block; a database block whose keyID was never populated or was cleared by an edit.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- filter group requires and/or combination
- filter nesting depth exceeds the maximum allowed
- validate attribute view context filter target
- at least one visible view is required
- attribute view custom color index
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/2de2648df1b87dcd.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/context_filter.go:31
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package av
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"strings"
)
const AttributeViewContextFilterSpec = 1
var (
ErrInvalidAttributeViewContextFilter = errors.New("invalid attribute view context filter")
ErrAttributeViewContextNotBound = errors.New("current document is not bound to the context filter target database")
)
// AttributeViewContextFilter 描述物理数据库块独有的上下文筛选配置。
type AttributeViewContextFilter struct {
Spec int `json:"spec"`
KeyID string `json:"keyID"`
}
// AttributeViewContextFilterField 描述可用于物理数据库块上下文筛选的关联字段。
type AttributeViewContextFilterField struct {
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
TargetAvID string `json:"targetAvID"`
}
// FilterContext 保存一次数据库块渲染所需的上下文筛选值,不参与持久化。View on GitHub (pinned to 9f775e8a12)