siyuan-note/siyuan · error
ErrKeyNotFound
ErrKeyNotFound
Error message
key not found
What it means
ErrKeyNotFound is returned when a lookup for a column key (field) inside an attribute view fails — e.g. preflightAttributeViewCellBindings cannot find the key a cell binding refers to, or value lookup helpers exhaust their candidate keys and fall through to this sentinel. It means the referenced field no longer exists in the database.
Solutions
- Reload the attribute view and verify the key id exists in av.KeyIDs/keys before writing
- Remove or remap stale key references (bindings, filters, rollups) after column deletion
- Handle the error by skipping/refreshing rather than retrying the same stale key
Example fix
// before
av.SetAttributeViewValue(keyID, rowID, value) // panics/errs if key deleted
// after
if _, ok := attrView.GetKey(keyID); !ok {
return fmt.Errorf("key %s missing; refresh schema", keyID)
}
av.SetAttributeViewValue(keyID, rowID, value) Defensive patterns
Strategy: validation
Validate before calling
if attrView.GetKey(keyID) == nil {
return fmt.Errorf("key %s no longer exists; refresh schema", keyID)
} Try / catch
if err := updateValue(...); err != nil {
if errors.Is(err, av.ErrKeyNotFound) {
attrView, _ = av.ParseAttributeView(avJSONPath) // reload and retry once
}
} Prevention
- Reload the attribute view after schema edits
- Clean up references to deleted keys in the same transaction
- Avoid persisting key ids across long-lived plugin sessions
When it happens
Trigger: Updating an attribute view value whose key id is not present in the loaded attribute view's key map; preflighting cell bindings after a column was deleted; looking up a key in a different view than the one containing it (per-view keys).
Common situations: Two devices concurrently editing the database: one deletes a column, the other adds values to it before syncing; plugins caching key ids across schema edits; templates or filters referencing a renamed/deleted column.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- database [ ] moved across notebook encryption boundaries
- unsupported parsed attribute view field
- [/api/av/batchSetAttributeViewBlockAttrs] parameter [rowID]…
- at least one visible view is required
- attribute view content is unavailable
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/acc1073f012413ff.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/av.go:1387
if !gulu.File.IsDir(av) {
if err := os.MkdirAll(av, 0755); err != nil {
logging.LogErrorf("create attribute view dir failed: %s", err)
return
}
}
return
}
func GetAttributeViewI18n(key string) string {
return util.AttrViewLangs[util.Lang][key].(string)
}
var (
ErrAttributeViewNotFound = errors.New("attribute view not found")
ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
ErrInvalidBoxID = errors.New("invalid box id")
ErrViewNotFound = errors.New("view not found")
ErrKeyNotFound = errors.New("key not found")
ErrItemNotFound = errors.New("item not found")
ErrWrongLayoutType = errors.New("wrong layout type")
ErrInvalidColumnAlign = errors.New("invalid column align")
ErrSpecTooNew = errors.New("attribute view spec is too new")
ErrRichTextSpecMismatch = errors.New("attribute view rich text requires storage spec 9")
ErrFilterTooDeep = errors.New("filter nesting depth exceeds the maximum allowed")
)
const (
NodeAttrNameAvs = "custom-avs" // 用于标记块所属的属性视图,逗号分隔 av id
NodeAttrView = "custom-sy-av-view" // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
NodeAttrVisibleViewIDs = "custom-sy-av-visible-views" // 用于标记数据库块显示的视图 ID,逗号分隔
NodeAttrContextFilter = "custom-sy-av-context-filter" // 用于保存数据库块独有的上下文筛选配置
NodeAttrViewStaticText = "custom-sy-av-s-text" // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔
)
View on GitHub (pinned to 9f775e8a12)