{"record":{"id":"20e00a38387237d2","repo":"siyuan-note/siyuan","slug":"key-s-not-found","errorCode":null,"errorMessage":"key [%s] not found","messagePattern":"key \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":2127,"sourceCode":"func AppendAttributeViewDetachedBlocksWithValues(avID string, blocksValues [][]*av.Value) (err error) {\n\tattrView, err := av.ParseAttributeView(avID)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"parse attribute view [%s] failed: %s\", avID, err)\n\t\treturn\n\t}\n\n\tnow := util.CurrentTimeMillis()\n\tvar blockIDs []string\n\tfor _, blockValues := range blocksValues {\n\t\tblockID := ast.NewNodeID()\n\t\tif v := blockValues[0]; \"\" != v.BlockID {\n\t\t\tblockID = v.BlockID\n\t\t}\n\t\tblockIDs = append(blockIDs, blockID)\n\t\tfor _, v := range blockValues {\n\t\t\tkeyValues, _ := attrView.GetKeyValues(v.KeyID)\n\t\t\tif nil == keyValues {\n\t\t\t\terr = fmt.Errorf(\"key [%s] not found\", v.KeyID)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tv.ID = ast.NewNodeID()\n\t\t\tv.BlockID = blockID\n\t\t\tv.Type = keyValues.Key.Type\n\t\t\tif av.KeyTypeBlock == v.Type {\n\t\t\t\tv.Block.Created = now\n\t\t\t\tv.Block.Updated = now\n\t\t\t\tv.Block.ID = \"\"\n\t\t\t\tv.Block.RefSubtype = \"\"\n\t\t\t}\n\t\t\tv.IsDetached = true\n\t\t\tv.CreatedAt = now\n\t\t\tv.UpdatedAt = now\n\t\t\tv.IsRenderAutoFill = false\n\t\t\tkeyValues.Values = append(keyValues.Values, v)\n","sourceCodeStart":2109,"sourceCodeEnd":2145,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view.go#L2109-L2145","documentation":"While copying/duplicating rows in an attribute view, each source value's key ID is resolved with GetKeyValues. If the attribute view contains a value whose key ID no longer resolves to a key (orphaned value or corrupted definition), this error aborts the operation. It signals internal data inconsistency in the .av file rather than a caller mistake.","triggerScenarios":"Row-duplication flows (e.g. adding a row based on an existing row) encountering a value whose key was deleted from the view definition, typically after manual editing, failed sync merge, or an older-format attribute view file.","commonSituations":"Sync conflicts leaving orphaned key values; hand-edited or partially written .av JSON; plugin operations that removed a key without cleaning up its values.","solutions":["Open the database in the SiYuan UI and remove/re-add the affected column to rebuild consistent key definitions.","Inspect the .av JSON under data/storage/av/ for the orphaned key ID and delete the stale value entry (keep a backup first).","Retry the row duplication after the attribute view definition is consistent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify every value's key resolves before duplicating\nconst keyIds = new Set(sourceRow.values.map(v => v.keyID));\nconst keys = new Set((await getAttrView(avID)).keys.map(k => k.id));\nif ([...keyIds].some(id => !keys.has(id))) throw new Error(\"orphaned values present; repair view first\");","typeGuard":null,"tryCatchPattern":"try { await duplicateRow(avID, srcRowID); } catch (e) { if (String(e).includes(\"key [\") && String(e).includes(\"] not found\")) await repairAvDefinition(avID); else throw e; }","preventionTips":["Remove a key via the UI so its values are cleaned up too","Back up data/storage/av before manual edits","Watch for sync conflicts touching .av files and re-index afterwards"],"tags":["attribute-view","orphaned-value","data-consistency"],"backgroundTag":"internal-invariant-violation","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"}