siyuan-note/siyuan · error
attribute view custom color
Error message
attribute view custom color [%d] is still in use by attribute view [%s]
What it means
When a palette update removes custom colors, the kernel first scans all attribute views in the workspace to build a usage map. If a color index being removed is still referenced by any attribute view, the update is aborted with this error to avoid breaking existing references.
Solutions
- First update or clear the attribute view cells (named by avID) that use the color index, then retry the palette update.
- Instead of removing the color, keep it in the palette or replace its usage with a built-in color via an attribute-view update.
- Re-run after the referencing blocks are edited/committed so the usage scan no longer sees the index.
Defensive patterns
Strategy: try-catch
Validate before calling
// Before removing palette colors, list attribute views and confirm the index is unused:
// usage := map[string]map[int]bool{} // avID -> color indexes in use
// if usage[avID][removedIndex] { defer removal } Try / catch
if err != nil && strings.Contains(err.Error(), "is still in use by attribute view") {
// parse avID from the message, update its cells, then retry
} Prevention
- Update attribute view cells off a custom color before removing the color from the palette
- Prefer replacing colors in place over deleting palette entries
- Avoid concurrent palette removals while documents with matching colors are open
When it happens
Trigger: SetInlineStyles / SetWorkspaceAVPalette / replaceWorkspaceAVPalette removing custom color entries whose indexes still appear in cells of one or more workspace attribute views (avID is named in the message).
Common situations: Cleaning up the workspace palette while some database (attribute view) cells still use those custom colors; a partially deleted attribute view leaving stale color indexes behind; concurrent edits where another document re-added a color between usage scan and removal.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- attribute view custom color
- database back relation values
- database entry [ ] changed since deletion was undone
- database entry [ ] has newer field values
- database field [ ] changed after the operation
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/f41a442db268c29d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:271
Version: InlineStylesVersion,
Styles: normalizedStyles,
Builtin: normalizedBuiltin,
Order: normalizeInlineStyleOrder(styles.Order, normalizedStyles),
AV: normalizedAV,
}
changedCustomColorIndexes := changedAttributeViewCustomColorIndexes(currentAV.Colors, ret.AV.Colors)
var customColorUsage map[string]map[int]struct{}
if 0 < len(changedCustomColorIndexes) {
removedIndexes := removedAttributeViewCustomColorIndexes(currentAV.Colors, ret.AV.Colors)
customColorUsage, err = workspaceAttributeViewCustomColorUsage(0 < len(removedIndexes))
if err != nil {
return nil, false, err
}
for _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {
indexes := customColorUsage[avID]
for index := range removedIndexes {
if _, used := indexes[index]; used {
return nil, false, fmt.Errorf("attribute view custom color [%d] is still in use by attribute view [%s]",
index, avID)
}
}
}
}
data, err := gulu.JSON.MarshalIndentJSON(ret, "", " ")
if err != nil {
return nil, false, fmt.Errorf("marshal inline styles failed: %w", err)
}
if maxInlineStylesFileSize < len(data) {
return nil, false, fmt.Errorf("inline styles file exceeds the %d byte limit", maxInlineStylesFileSize)
}
dataPath := inlineStylesPath()
oldData, readErr := filelock.ReadFile(dataPath)
if readErr != nil && !os.IsNotExist(readErr) {
return nil, false, fmt.Errorf("read inline styles failed: %w", readErr)
}View on GitHub (pinned to 9f775e8a12)