siyuan-note/siyuan · error

invalid database option name

Error message

invalid database option name

What it means

removeAttributeViewColumnOptionValues expects operation.Data to be a string naming the select-option to remove from a database column. If the type assertion fails (Data is not a string), it returns this sentinel error, because without a valid option name the removal cannot proceed.

Solutions

  1. Verify operation.Data is a plain string holding the option name before dispatching the operation
  2. Fix the producer of the Operation to set Data to the option name string
  3. If replaying old history, migrate/normalize old operation payloads to the current format

Example fix

// before
const op = { action: "removeAttributeViewColumnOptionValues", id: keyID, data: { name: "todo" } }
// after
const op = { action: "removeAttributeViewColumnOptionValues", id: keyID, data: "todo" }
Defensive patterns

Strategy: validation

Validate before calling

if typeof op.data !== "string" || op.data.length === 0 { throw new Error("option name must be a non-empty string") }

Try / catch

err := mutateAttributeViewOption(op)
if err != nil && err.Error() == "invalid database option name" {
    // op.Data was not a string; normalize and retry
}

Prevention

When it happens

Trigger: Calling the undo/redo mutation path (mutateAttributeViewOption with remove-option operation) when operation.Data was marshalled/stored as a non-string (e.g. an object, map, or nil from a malformed operation payload).

Common situations: Undo/redo replaying operations persisted by an older version that stored option data as an object; plugins pushing hand-crafted Operation payloads with wrong Data type; JSON round-trip losing the string.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view_option_undo.go:171

	return nil
}

func removeAttributeViewColumnOption(operation *Operation) (err error) {
	tx := &Transaction{trees: map[string]*parse.Tree{}}
	defer func() { tx.finishAttributeViewMutation(err != nil) }()
	return tx.mutateAttributeViewOption(operation, true)
}

func updateAttributeViewColumnOption(operation *Operation) (err error) {
	tx := &Transaction{trees: map[string]*parse.Tree{}}
	defer func() { tx.finishAttributeViewMutation(err != nil) }()
	return tx.mutateAttributeViewOption(operation, false)
}

func removeAttributeViewColumnOptionValues(attrView *av.AttributeView, operation *Operation) (err error) {
	optName, ok := operation.Data.(string)
	if !ok {
		return errors.New("invalid database option name")
	}

	key, err := attrView.GetKey(operation.ID)
	if err != nil {
		return
	}

	for i, opt := range key.Options {
		if optName == opt.Name {
			key.Options = append(key.Options[:i], key.Options[i+1:]...)
			break
		}
	}
	attrView.RemoveNewItemTemplateSelectOption(operation.ID, optName)

	for _, keyValues := range attrView.KeyValues {
		if keyValues.Key.ID != operation.ID {
			continue

View on GitHub (pinned to 9f775e8a12)