siyuan-note/siyuan · error
key [ ] not found
Error message
key [%s] not found
What it means
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.
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// verify every value's key resolves before duplicating
const keyIds = new Set(sourceRow.values.map(v => v.keyID));
const keys = new Set((await getAttrView(avID)).keys.map(k => k.id));
if ([...keyIds].some(id => !keys.has(id))) throw new Error("orphaned values present; repair view first"); Try / catch
try { await duplicateRow(avID, srcRowID); } catch (e) { if (String(e).includes("key [") && String(e).includes("] not found")) await repairAvDefinition(avID); else throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Sync conflicts leaving orphaned key values; hand-edited or partially written .av JSON; plugin operations that removed a key without cleaning up its values.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- [/api/av/batchSetAttributeViewBlockAttrs] parameter [rowID]…
- at least one visible view is required
- attribute view content is unavailable
- attribute view custom color
- attribute view custom color
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/20e00a38387237d2.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view.go:2127
func AppendAttributeViewDetachedBlocksWithValues(avID string, blocksValues [][]*av.Value) (err error) {
attrView, err := av.ParseAttributeView(avID)
if err != nil {
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
return
}
now := util.CurrentTimeMillis()
var blockIDs []string
for _, blockValues := range blocksValues {
blockID := ast.NewNodeID()
if v := blockValues[0]; "" != v.BlockID {
blockID = v.BlockID
}
blockIDs = append(blockIDs, blockID)
for _, v := range blockValues {
keyValues, _ := attrView.GetKeyValues(v.KeyID)
if nil == keyValues {
err = fmt.Errorf("key [%s] not found", v.KeyID)
return
}
v.ID = ast.NewNodeID()
v.BlockID = blockID
v.Type = keyValues.Key.Type
if av.KeyTypeBlock == v.Type {
v.Block.Created = now
v.Block.Updated = now
v.Block.ID = ""
v.Block.RefSubtype = ""
}
v.IsDetached = true
v.CreatedAt = now
v.UpdatedAt = now
v.IsRenderAutoFill = false
keyValues.Values = append(keyValues.Values, v)
View on GitHub (pinned to 9f775e8a12)