siyuan-note/siyuan · error
attribute view is required
Error message
attribute view is required
What it means
configureCreatedAttributeView is an internal step that wires the view name, primary key, and initial view configuration into a freshly created av.AttributeView. It refuses a nil attribute view because there is nothing to configure and proceeding would panic later.
Source
Thrown at kernel/model/attribute_view_create.go:126
view, viewErr := attrView.GetFirstView()
if nil != viewErr {
return nil, databaseCreationError(viewErr, cleanupCreatedAttributeView(blockID, avID))
}
if err = SetDatabaseBlockView(blockID, avID, view.ID); nil != err {
return nil, databaseCreationError(err, cleanupCreatedAttributeView(blockID, avID))
}
if bt := treenode.GetBlockTree(blockID); nil != bt {
util.PushReloadProtyle(bt.RootID)
}
ReloadAttrView(avID)
ret = &AttributeViewCreateResult{BlockID: blockID, AvID: avID, ViewID: view.ID, AttributeView: attrView}
return
}
func configureCreatedAttributeView(attrView *av.AttributeView, name, primaryKeyName string, preparedKeys []*av.Key) (err error) {
if nil == attrView {
return errors.New("attribute view is required")
}
currentView, err := attrView.GetFirstView()
if nil != err {
return
}
blockKeyValues := attrView.GetBlockKeyValues()
if nil == blockKeyValues || nil == blockKeyValues.Key {
return errors.New("attribute view has no primary key field")
}
if name = strings.TrimSpace(name); "" != name {
name = strings.ReplaceAll(name, "\n", " ")
if 512 < utf8.RuneCountInString(name) {
name = string([]rune(name)[:512])
}
attrView.Name = name
}
if primaryKeyName = strings.TrimSpace(primaryKeyName); "" != primaryKeyName {View on GitHub (pinned to 8641553a1f)
Solutions
- Construct or load a valid *av.AttributeView (e.g. via av.NewAttributeView) before calling configureCreatedAttributeView
- In tests, build a fixture attribute view with at least a block key before invoking the helper
- If hit in production paths, check that the earlier creation steps returned non-nil attrView and an error was not swallowed
Example fix
// before err := configureCreatedAttributeView(nil, "My DB", "Name", keys) // after attrView := av.NewAttributeView(ast.NewNodeID()) err := configureCreatedAttributeView(attrView, "My DB", "Name", keys)
Defensive patterns
Strategy: validation
Validate before calling
if attrView == nil {
return errors.New("attrView must be constructed before configuration")
} Type guard
func isNilAttrView(v *av.AttributeView) bool { return v == nil } Try / catch
if err := configureCreatedAttributeView(attrView, name, pk, keys); err != nil {
return fmt.Errorf("configure created attribute view: %w", err)
} Prevention
- In tests, construct fixtures via the same factory functions production code uses
- Never pass a nil attribute view; build one with av.NewAttributeView first
- Ensure creation and configuration happen in one guarded sequence
When it happens
Trigger: Calling configureCreatedAttributeView directly (tests do this) with a nil *av.AttributeView; in production this indicates a bug where CreateAttributeViewDatabase produced a nil attrView without returning an error.
Common situations: Unit tests exercising the configure step against a hand-built or nil view; a refactoring that changed the construction order so attrView is nil when configuration runs.
Related errors
- attribute view item markdown is nil
- clone attribute view [%s] failed
- clone attribute view [%s] views failed
- clone attribute view [%s] view failed
- copied attribute view [%s] view mapping not found
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/3c80f0d77a6e3f3c.
Report an issue: GitHub.