siyuan-note/siyuan · error
database history contains an invalid value
Error message
database history contains an invalid value
What it means
A parsed database history snapshot contains a nil Value inside one of its fields. Values must all be non-nil for the snapshot to be restorable; a nil value means the serialized history is incomplete or corrupt, so the engine rejects it before any restore attempt.
Solutions
- Pick a different, intact history snapshot to restore
- Restore the corrupt history file from a backup copy
- Generate a new snapshot by editing the database again, then restore from it
- Check the storage/sync layer for reliability problems if snapshots keep arriving corrupt
Defensive patterns
Strategy: validation
Validate before calling
function hasValidValues(view) {
return view.keyValues.every(kv => kv.values.every(v => v));
} Type guard
const allValuesPresent = (view) => view.keyValues.every(kv => kv.values && kv.values.every(v => v != null));
Prevention
- Ensure sync/backup completes before restoring history snapshots
- Avoid mixing history files across SiYuan versions
- Regenerate snapshots rather than repairing corrupt ones by hand
- Monitor storage health where data/history lives
When it happens
Trigger: readBoundAttributeViewHistory walking kv.Values where any value pointer is nil — from truncated history writes, interrupted snapshots, or externally modified history data.
Common situations: Interrupted backup/sync while the snapshot was written; corrupted storage; mixing history files from different SiYuan versions with divergent serialization.
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
- database back relation value is invalid
- database history contains an invalid field
- database back relation changed since document deletion
- database entry [ ] has a different binding
- database field [ ] changed since document deletion
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/f49f129732221a4b.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view_block_history.go:51
return nil, err
}
} else if util.IsCiphertext(data) {
return nil, errors.New("encrypted database history has no notebook context")
}
view, err := av.ParseAttributeViewData(avID, data)
if err != nil {
return nil, err
}
if view.ID != avID {
return nil, errors.New("database history ID does not match its filename")
}
for _, kv := range view.KeyValues {
if kv == nil || kv.Key == nil {
return nil, errors.New("database history contains an invalid field")
}
for _, value := range kv.Values {
if value == nil {
return nil, errors.New("database history contains an invalid value")
}
}
}
if view.GetBlockKeyValues() == nil {
return nil, errors.New("database history has no primary field")
}
for _, layout := range view.Views {
if layout == nil {
return nil, errors.New("database history contains an invalid view")
}
for _, group := range layout.Groups {
if group == nil {
return nil, errors.New("database history contains an invalid group")
}
}
}
return view, nil
}View on GitHub (pinned to 9f775e8a12)