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
- Pass a non-null Data payload containing the colors (and order) to set
- To clear colors, send an empty list in Data rather than null
- 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
- Always include a Data object, even when empty
- Use explicit empty arrays to clear palettes
- Validate request objects in a shared request builder
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
- wrong layout type
- filter nesting depth exceeds the maximum allowed
- invalid id
- ErrFilterTooDeep
- attribute view custom colors count exceeds the %d item limit
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/79f37d4d1c5760c2.
Report an issue: GitHub.