{"record":{"id":"73b6f7fe4782af9a","repo":"siyuan-note/siyuan","slug":"erritemnotfound","errorCode":"ErrItemNotFound","errorMessage":"item not found","messagePattern":"item not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1344,"sourceCode":"\t\tif err := os.MkdirAll(av, 0755); err != nil {\n\t\t\tlogging.LogErrorf(\"create attribute view dir failed: %s\", err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\nfunc GetAttributeViewI18n(key string) string {\n\treturn util.AttrViewLangs[util.Lang][key].(string)\n}\n\nvar (\n\tErrAttributeViewNotFound  = errors.New(\"attribute view not found\")\n\tErrInvalidAttributeViewID = errors.New(\"invalid attribute view id\")\n\tErrInvalidBoxID           = errors.New(\"invalid box id\")\n\tErrViewNotFound           = errors.New(\"view not found\")\n\tErrKeyNotFound            = errors.New(\"key not found\")\n\tErrItemNotFound           = errors.New(\"item not found\")\n\tErrWrongLayoutType        = errors.New(\"wrong layout type\")\n\tErrInvalidColumnAlign     = errors.New(\"invalid column align\")\n\tErrSpecTooNew             = errors.New(\"attribute view spec is too new\")\n\tErrRichTextSpecMismatch   = errors.New(\"attribute view rich text requires storage spec 9\")\n\tErrFilterTooDeep          = errors.New(\"filter nesting depth exceeds the maximum allowed\")\n)\n\nconst (\n\tNodeAttrNameAvs        = \"custom-avs\"                  // 用于标记块所属的属性视图，逗号分隔 av id\n\tNodeAttrView           = \"custom-sy-av-view\"           // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443\n\tNodeAttrVisibleViewIDs = \"custom-sy-av-visible-views\"  // 用于标记数据库块显示的视图 ID，逗号分隔\n\tNodeAttrContextFilter  = \"custom-sy-av-context-filter\" // 用于保存数据库块独有的上下文筛选配置\n\tNodeAttrViewStaticText = \"custom-sy-av-s-text\"         // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049\n\n\tNodeAttrViewNames = \"av-names\" // 用于临时标记块所属的属性视图名称，空格分隔\n)\n","sourceCodeStart":1326,"sourceCodeEnd":1361,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/av.go#L1326-L1361","documentation":"ErrItemNotFound is returned when a row (item/block value) with the given itemID does not exist within a key's values — e.g. updateAttributeViewValue finds no blockVal for the item and aborts with av.ErrItemNotFound instead of silently creating a dangling row update.","triggerScenarios":"Calling updateAttributeViewValue (or higher-level value-update APIs) with an itemID that has no row in the target key's values — the row was deleted, belongs to another database, or the ID was mistyped; TestUpdateAttributeViewValueRejectsMissingItem asserts this behavior.","commonSituations":"Plugin holding a row ID while the user deleted the row; updating a row in the wrong attribute view; row IDs from a stale frontend cache after a database rebuild; concurrent deletion racing an update.","solutions":["Re-read the AV and confirm the item exists (GetBlockValue / GetValue) before updating","Check errors.Is(err, av.ErrItemNotFound) and re-create the row if it should exist","Ensure the itemID comes from the same attribute view as the keyID being targeted","Refresh the frontend/plugin row cache after any AddAttributeViewBlocksWithValues or remove-blocks operation"],"exampleFix":"// before\nupdateAttributeViewValue(nil, attrView, keyID, missingItemID, val, false) // ErrItemNotFound\n// after\nif attrView.GetBlockValue(itemID) == nil {\n    return fmt.Errorf(\"row %s does not exist in av %s; re-add it first\", itemID, attrView.ID)\n}\nupdateAttributeViewValue(nil, attrView, keyID, itemID, val, false)","handlingStrategy":"type-guard","validationCode":"if attrView.GetBlockValue(itemID) == nil {\n    return fmt.Errorf(\"item %s not present in av %s\", itemID, attrView.ID)\n}","typeGuard":"func itemExists(attrView *av.AttributeView, itemID string) bool {\n    return attrView.GetBlockValue(itemID) != nil\n}","tryCatchPattern":"err := updateAttrViewValue(avID, keyID, itemID, value)\nif errors.Is(err, av.ErrItemNotFound) {\n    log.Warnf(\"row %s was deleted; skipping update\", itemID)\n    return nil // or re-add the row via AddAttributeViewBlocksWithValues\n}","preventionTips":["Refresh row caches after any row deletion or database rebuild","Confirm the itemID belongs to the same attribute view as keyID","Skip-or-recreate: decide explicitly whether a missing row should be skipped or re-added"],"tags":["go","attribute-view","not-found","row"],"backgroundTag":"record-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}