siyuan-note/siyuan · error

previous ID and next ID cannot both be specified

Error message

previous ID and next ID cannot both be specified

What it means

CreateAttributeViewDatabase accepts an optional insertion position: either previousID (insert after this block) or nextID (insert before this block), but never both. Specifying both is ambiguous, so the function rejects the call upfront. This is a mutually-exclusive-options guard on the position parameters.

Solutions

  1. Set only previousID (insert after it) or only nextID (insert before it); leave the other empty
  2. To insert at a specific position choose the neighbor that matches your intent and null out the other parameter
  3. If you need both bounds for validation, validate yourself first, then pass just one neighbor

Example fix

// before
model.CreateAttributeViewDatabase(parentID, prevID, nextID, name, pk, layout, keys)
// after
prevArg := prevID
nextArg := ""
model.CreateAttributeViewDatabase(parentID, prevArg, nextArg, name, pk, layout, keys)
Defensive patterns

Strategy: validation

Validate before calling

if previousID != "" && nextID != "" { return errors.New("specify only one of previousID/nextID") }
err := model.CreateAttributeViewDatabase(parentID, previousID, nextID, name, pk, layout, keys)

Try / catch

result, err := model.CreateAttributeViewDatabase(parentID, previousID, nextID, ...)
if err != nil && strings.Contains(err.Error(), "cannot both be specified") {
    nextID = "" // retry with previousID only
    result, err = model.CreateAttributeViewDatabase(parentID, previousID, "", ...)
}

Prevention

When it happens

Trigger: Calling CreateAttributeViewDatabase with both previousID and nextID set to non-empty values; API handler databaseCreate forwarding both fields from a request that filled both.

Common situations: Client code copying an insertion struct that carries both neighbors; generic UI logic that always populates both fields; scripts that set the previous sibling and next sibling at once.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/f2c729ff7f74a0d8. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view_create.go:55

	Icon string `json:"icon,omitempty"`
}

// AttributeViewCreateResult 描述创建数据库后可供调用方继续操作的标识和数据。
type AttributeViewCreateResult struct {
	BlockID       string
	AvID          string
	ViewID        string
	AttributeView *av.AttributeView
}

// CreateAttributeViewDatabase 创建数据库块和对应属性视图,并按照 keySpecs 的顺序初始化字段。
func CreateAttributeViewDatabase(parentID, previousID, nextID, name, primaryKeyName string, layout av.LayoutType,
	keySpecs []*AttributeViewCreateKey) (ret *AttributeViewCreateResult, err error) {
	if "" == parentID {
		return nil, errors.New("parent ID is required")
	}
	if "" != previousID && "" != nextID {
		return nil, errors.New("previous ID and next ID cannot both be specified")
	}
	if "" == previousID && "" == nextID {
		if err = treenode.CheckContainerParent(parentID); nil != err {
			return nil, err
		}
	}
	if "" == layout {
		layout = av.LayoutTypeTable
	}
	switch layout {
	case av.LayoutTypeTable, av.LayoutTypeGallery, av.LayoutTypeKanban:
	default:
		return nil, av.ErrWrongLayoutType
	}

	preparedKeys := make([]*av.Key, 0, len(keySpecs))
	for _, spec := range keySpecs {
		if nil == spec || "" == strings.TrimSpace(spec.Name) || "" == strings.TrimSpace(spec.Type) {

View on GitHub (pinned to 9f775e8a12)