siyuan-note/siyuan · error

attribute view custom colors must not be empty

Error message

attribute view custom colors must not be empty

What it means

setAttrViewCustomColors guard: the operation payload for setting attribute-view custom colors arrived with operation.Data null. The request must carry the colors object; an absent payload is rejected before marshalling.

Source

Thrown at kernel/model/attribute_view.go:8898

			Order  []string                       `json:"order"`
		}{}
		if err = gulu.JSON.UnmarshalJSON(data, &decoded); nil != err {
			return
		}
		return decoded.Colors, decoded.Order, nil
	}
	colors = []*av.AttributeViewCustomColor{}
	err = gulu.JSON.UnmarshalJSON(data, &colors)
	return
}

func setAttrViewCustomColors(operation *Operation) (err error) {
	attrView, err := avParseView(operation.AvID, operation.BlockID)
	if nil != err {
		return
	}
	if nil == operation.Data {
		return errors.New("attribute view custom colors must not be empty")
	}

	data, err := gulu.JSON.MarshalJSON(operation.Data)
	if nil != err {
		return
	}
	colors, order, err := parseAttrViewCustomColorsData(data)
	if nil != err {
		return
	}
	colors, err = av.NormalizeAttributeViewCustomColors(colors, true)
	if nil != err {
		return
	}

	oldColors := []*av.AttributeViewCustomColor{}
	oldOrder := []string{}
	if styles, stylesErr := GetInlineStyles(); nil == stylesErr && styles != nil && styles.AV != nil {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Pass a non-null Data payload containing the colors (and order) to set
  2. To clear colors, send an empty list in Data rather than null
  3. Validate the request object before sending

Example fix

// before
setCustomColors(avID, null)
// after
setCustomColors(avID, { colors: [], order: [] })
Defensive patterns

Strategy: validation

Validate before calling

if (payload.data == null) throw new Error("custom colors payload must not be null");

Type guard

const hasColors = (op) => op.data != null;

Prevention

When it happens

Trigger: Calling the custom-colors API with an operation whose Data field is null/omitted.

Common situations: Plugin builds the request dynamically and drops the data field when the palette is empty; a JSON serialization bug omits null fields; clearing colors done by sending null instead of an empty array/object.

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@8641553a1f (2026-09-11). Data as JSON: /api/errors/79f37d4d1c5760c2. Report an issue: GitHub.