siyuan-note/siyuan · error
duplicate workspace attribute view builtin color update
Error message
duplicate workspace attribute view builtin color update [%d]
What it means
Each builtin color slot may be patched at most once per SetWorkspaceAVPalette call. A repeated index (tracked in updatedIndexes) fails with 'duplicate workspace attribute view builtin color update [%d]', preventing ambiguous conflicting writes to the same slot.
Solutions
- Deduplicate update.BuiltinColors by Index (keep the last patch) before calling
- Rebuild the patch list from final desired state rather than appending incremental edits
- At the API boundary, reject or merge duplicate-index payloads
Example fix
// before
ret, _, err := model.SetWorkspaceAVPalette(&model.WorkspaceAVPaletteUpdate{BuiltinColors: patches})
// after
latest := map[int]*model.WorkspaceAVBuiltinColorUpdate{}
for _, p := range patches {
latest[p.Index] = p
}
unique := make([]*model.WorkspaceAVBuiltinColorUpdate, 0, len(latest))
for _, p := range latest {
unique = append(unique, p)
}
ret, _, err := model.SetWorkspaceAVPalette(&model.WorkspaceAVPaletteUpdate{BuiltinColors: unique}) Defensive patterns
Strategy: validation
Validate before calling
seen := map[int]bool{}
for _, p := range patches {
if seen[p.Index] {
return fmt.Errorf("duplicate builtin color index %d", p.Index)
}
seen[p.Index] = true
} Prevention
- Deduplicate patches by index before sending
- Build patches from final state, not incremental UI events
- Test palette-save flows that fire multiple change events
When it happens
Trigger: Calling `SetWorkspaceAVPalette` where two or more elements of update.BuiltinColors share the same Index, detected via the updatedIndexes map.
Common situations: Frontend accumulates patches across UI events without deduplicating; merging palette changes from multiple sources produces repeated indexes.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- duplicated attribute view custom color index
- duplicated new item template id
- at least one visible view is required
- attribute view custom color index
- attribute view custom color must not be null
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/4bf0fe879a938782.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:198
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{
Index: patch.Index,
Light: patch.Light,
Dark: patch.Dark,
})
}
filteredHidden := current.Builtin.Hidden.AV[:0]
for _, index := range current.Builtin.Hidden.AV {View on GitHub (pinned to 9f775e8a12)