siyuan-note/siyuan · error
workspace attribute view builtin color update must not be…
Error message
workspace attribute view builtin color update must not be null
What it means
Within SetWorkspaceAVPalette, each entry of update.BuiltinColors must be a non-nil patch struct. A nil element triggers 'workspace attribute view builtin color update must not be null', aborting the whole palette update before any change is persisted.
Solutions
- Filter out nil elements from update.BuiltinColors before calling
- Validate the request payload (no null array items) at the API boundary
- Fix the frontend code that builds the builtin color patches array
Example fix
// before
patches := collectBuiltinColorPatches()
ret, _, err := model.SetWorkspaceAVPalette(&model.WorkspaceAVPaletteUpdate{BuiltinColors: patches})
// after
patches := collectBuiltinColorPatches()
patches = slices.DeleteFunc(patches, func(p *model.WorkspaceAVBuiltinColorUpdate) bool { return p == nil })
ret, _, err := model.SetWorkspaceAVPalette(&model.WorkspaceAVPaletteUpdate{BuiltinColors: patches}) Defensive patterns
Strategy: validation
Validate before calling
for i, p := range update.BuiltinColors {
if p == nil {
return fmt.Errorf("builtinColors[%d] must not be null", i)
}
} Try / catch
if _, _, err := model.SetWorkspaceAVPalette(update); err != nil {
return apiError(err)
} Prevention
- Validate JSON arrays for null items at the API boundary
- Filter nil patches before building WorkspaceAVPaletteUpdate
- Add a frontend test for the patches array construction
When it happens
Trigger: Calling `SetWorkspaceAVPalette` with `update.BuiltinColors` containing a nil *WorkspaceAVBuiltinColorUpdate element, e.g. a JSON array with a null item.
Common situations: Frontend constructs the patches array programmatically and appends a nil entry; JSON payload like "builtinColors":[null].
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 custom colors must not be empty
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/d72d7524f052554d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:191
// SetWorkspaceAVPalette 只更新数据库颜色配置,保留其他窗口可能同时修改的行级样式设置。
func SetWorkspaceAVPalette(update *WorkspaceAVPaletteUpdate) (ret *InlineStyles, changed bool, err error) {
waitForSyncingStorages()
inlineStylesLock.Lock()
defer inlineStylesLock.Unlock()
if update == nil {
return nil, false, errors.New("workspace attribute view palette update must not be null")
}
current, err := loadInlineStyles()
if err != nil {
return nil, false, err
}
currentAV := current.AV
current.AV = &InlineStyleAV{Colors: update.Colors, Order: update.Order}
updatedIndexes := map[int]struct{}{}
for _, patch := range update.BuiltinColors {
if patch == nil {
return nil, false, errors.New("workspace attribute view builtin color update must not be null")
}
if patch.Index < minBuiltinColorIndex || neutralAVColorIndex < patch.Index {
return nil, false, fmt.Errorf("builtin color index [%d] must be between %d and %d", patch.Index,
minBuiltinColorIndex, neutralAVColorIndex)
}
if _, duplicated := updatedIndexes[patch.Index]; duplicated {
return nil, false, fmt.Errorf("duplicate workspace attribute view builtin color update [%d]", patch.Index)
}
updatedIndexes[patch.Index] = struct{}{}
filtered := current.Builtin.Colors[:0]
for _, color := range current.Builtin.Colors {
if color.Index != patch.Index {
filtered = append(filtered, color)
}
}
current.Builtin.Colors = filtered
if patch.Customized {
current.Builtin.Colors = append(current.Builtin.Colors, &InlineStyleBuiltinColor{View on GitHub (pinned to 9f775e8a12)