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 requires operation.Data to carry the new custom color palette; a nil Data payload is rejected because there is nothing to persist. The kernel marshals Data to JSON to build the color set, so the payload must be present and a JSON-marshalable structure.
Solutions
- Include a non-null data payload containing the colors (and any order fields) in the request
- Check the API client isn't dropping undefined/null fields before sending
- Pass an empty-but-valid structure if the intent is to represent no colors, per the API's expected schema
- Refer to the kernel handler for the exact expected data shape
Example fix
// before
fetchPost("/api/av/setAttrViewCustomColors", {avID, blockID, data: null})
// after
fetchPost("/api/av/setAttrViewCustomColors", {avID, blockID, data: {colors: [...], order: [...]}}) Defensive patterns
Strategy: validation
Validate before calling
if (request.data == null) throw new Error("setAttrViewCustomColors requires a non-null data payload"); Try / catch
try { await setCustomColors(req); } catch (e) { if (String(e).includes("custom colors must not be empty")) { /* populate req.data with the palette */ } else { throw e; } } Prevention
- Always construct the full data object (colors + order) before calling the API
- Check API wrappers for null/undefined field stripping
- Validate request bodies in plugin code before sending
When it happens
Trigger: Calling the set-attribute-view-custom-colors API with no 'data' field in the request body, or explicitly setting data to null.
Common situations: Plugin sending an options object where only some fields are populated; frontend refactor dropping the data field; generic API wrapper that strips null/undefined fields incorrectly.
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
- at least one visible view is required
- attribute view custom color index
- attribute view custom color must not be null
- attribute view custom colors count exceeds the
- attribute view is not unused
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/79f37d4d1c5760c2.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view.go:8885
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 9f775e8a12)