siyuan-note/siyuan · error

new option name must not be empty

Error message

new option name must not be empty

What it means

When optionUpdate supplies newName, the resulting name must be non-empty after trimming, since names are the identity of select options. An explicitly provided but blank newName is rejected instead of being silently ignored.

Solutions

  1. Omit newName (or send null) when the name should not change — only a non-null string triggers rename validation
  2. Provide a non-empty trimmed newName
  3. Validate the new name in the UI before submitting

Example fix

// before
{avID, keyID, setting: "optionUpdate", data: {name: "Todo", newName: ""}}
// after
{avID, keyID, setting: "optionUpdate", data: {name: "Todo", color: "2"}}
Defensive patterns

Strategy: validation

Validate before calling

if (newName !== undefined && newName !== null && newName.trim() === "") {
  throw new Error("blank newName: omit the field to keep the name");
}

Prevention

When it happens

Trigger: Calling UpdateAttributeViewKeyConfig with setting "optionUpdate" and data {name: "Existing", newName: ""} or newName of only whitespace.

Common situations: UI clearing the rename input then submitting; code that always includes newName and sends the empty string when untouched (should omit the field or send null instead).

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view_key_config.go:243

	}
	var config struct {
		Name    string  `json:"name"`
		NewName *string `json:"newName"`
		Color   *string `json:"color"`
		Desc    *string `json:"desc"`
	}
	if err := decodeAttributeViewKeyConfig(value, &config); nil != err {
		return err
	}
	option := key.GetOption(config.Name)
	if nil == option {
		return errors.New("optionUpdate must name an existing option")
	}
	name, color, desc := option.Name, option.Color, option.Desc
	if nil != config.NewName {
		name = strings.TrimSpace(*config.NewName)
		if "" == name {
			return errors.New("new option name must not be empty")
		}
		if name != option.Name && nil != key.GetOption(name) {
			return errors.New("new option name already exists")
		}
	}
	if nil != config.Color {
		color = *config.Color
		if attrView.FilterColorValue(color) != color {
			return errors.New("invalid option color")
		}
	}
	if nil != config.Desc {
		desc = *config.Desc
	}
	if name == option.Name {
		op.Data = []*av.SelectOption{{Name: name, Color: color, Desc: desc}}
		return updateAttributeViewColumnOptions(op)
	}

View on GitHub (pinned to 9f775e8a12)