siyuan-note/siyuan · warning

block updates are empty

Error message

block updates are empty

What it means

Returned by buildBlockUpdateOperations when len(inputs) < 1. The function is the entry point for assembling block-update operations; an empty input slice has nothing to apply, so it rejects immediately with errors.New before doing any work.

Source

Thrown at kernel/model/block_update.go:85

	for _, queued := range takeQueuedTransactions() {
		flushTx(queued)
	}

	operations, rootIDs, err := build(inputs)
	if err != nil {
		return nil, nil, err
	}

	transaction := &Transaction{DoOperations: operations}
	if err = performTxSyncLocked(transaction); err != nil {
		return nil, nil, err
	}
	return []*Transaction{transaction}, rootIDs, nil
}

func buildBlockUpdateOperations(inputs []BlockUpdateInput, resolveTree blockUpdateTreeResolver, loadTree blockUpdateTreeLoader) (operations []*Operation, rootIDs []string, err error) {
	if 1 > len(inputs) {
		return nil, nil, errors.New("block updates are empty")
	}

	luteEngine := util.NewLute()
	rootIDSet := map[string]struct{}{}
	treeCache := map[blockUpdateTreeKey]*parse.Tree{}
	for _, input := range inputs {
		if !ast.IsNodeIDPattern(input.ID) {
			return nil, nil, fmt.Errorf("invalid block ID [%s]", input.ID)
		}

		data, dataTree, parseErr := parseBlockUpdateData(input.Data, input.DataType, luteEngine)
		if parseErr != nil {
			return nil, nil, parseErr
		}

		var oldTree *parse.Tree
		var cacheKey blockUpdateTreeKey
		hasCacheKey := false

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Skip the API call entirely when inputs is empty - it is a no-op by definition.
  2. Add a guard at the caller: if len(inputs) == 0 return nil without invoking the kernel.
  3. Audit the client gather logic to understand why an empty batch was submitted.

Example fix

// before
_, _, err := buildBlockUpdateOperations(inputs, resolver, loader)

// after
if len(inputs) == 0 {
    return nil, nil, nil
}
_, _, err := buildBlockUpdateOperations(inputs, resolver, loader)
Defensive patterns

Strategy: validation

Validate before calling

if len(inputs) == 0 {
    return nil, nil, nil // no-op
}

Prevention

When it happens

Trigger: API or kernel call with an empty inputs array; client-side gather loop produced zero entries due to a UI bug; upstream filter that removed all inputs but still forwarded the call.

Common situations: Frontend selection cleared before the request fired; batch caller not skipping the empty case; misrouted call where another endpoint should have handled the no-op.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/c6d72ecc0d9d4003. Report an issue: GitHub.