siyuan-note/siyuan · error
workspace attribute view palette update must not be null
Error message
workspace attribute view palette update must not be null
What it means
SetWorkspaceAVPalette updates the workspace attribute-view color palette under the inline-styles lock. It rejects a nil update argument with 'workspace attribute view palette update must not be null' before touching stored styles.
Solutions
- Check the update pointer for nil before calling and return a client-side validation error
- In the API layer, reject requests with missing palette payload before invoking the kernel function
- Ensure the frontend always sends colors/order fields when saving the palette
Example fix
// before
ret, changed, err := model.SetWorkspaceAVPalette(update)
// after
if update == nil {
return nil, errors.New("palette update payload is required")
}
ret, changed, err := model.SetWorkspaceAVPalette(update) Defensive patterns
Strategy: type-guard
Validate before calling
if update == nil {
return errors.New("palette update payload is required")
} Type guard
func validPaletteUpdate(u *model.WorkspaceAVPaletteUpdate) bool {
return u != nil && u.Colors != nil && u.Order != nil
} Try / catch
ret, changed, err := model.SetWorkspaceAVPalette(update)
if err != nil {
return nil, err
} Prevention
- Deserialize request bodies with explicit empty-payload rejection
- Always send colors and order when saving the palette
- Unit-test the API handler with a nil payload
When it happens
Trigger: Calling `SetWorkspaceAVPalette(nil)`, e.g. from an API handler whose request body failed to deserialize into a *WorkspaceAVPaletteUpdate and left the pointer nil.
Common situations: Frontend sends an empty/missing payload that the API layer maps to nil; a caller passes a pointer obtained from a failed decode.
Related errors
- attribute view item markdown is nil
- [/api/av/batchSetAttributeViewBlockAttrs] parameter [rowID]…
- cannot add an attribute view block key
- config must contain exactly one setting; use separate calls…
- Field [keyIDs] is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/972b0c36664a4628.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:180
waitForSyncingStorages()
inlineStylesLock.Lock()
defer inlineStylesLock.Unlock()
current, err := loadInlineStyles()
if err != nil {
return nil, false, err
}
return setInlineStylesData(styles, current.AV)
}
// 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)View on GitHub (pinned to 9f775e8a12)