siyuan-note/siyuan · error

attribute view custom color

Error message

attribute view custom color [%d] is still in use

What it means

When replacing the workspace attribute-view color palette, a custom color that some views still reference cannot be removed. The kernel computes which old color indexes are still used by views; if a color slated for removal (not retained) is still in use, the whole palette replacement is rejected, reporting the offending color index.

Solutions

  1. Retain (keep) every color index that is currently in use, or first remap those views to other colors, then replace the palette
  2. Enumerate views' color usage before building the new palette and include all used indexes
  3. Return/report the offending index from the error message and fix it in the payload
  4. Retry the palette change after the dependent views are updated

Example fix

// before
const newColors = palette.filter(c => userRemoved(c)); // may drop colors still in use
// after
const used = collectUsedColorIndexes(attrViews);
const newColors = palette.filter(c => userRemoved(c) || used.has(c.index)); // retain in-use colors
Defensive patterns

Strategy: validation

Validate before calling

const used = collectUsedColorIndexes(attrViews); // indexes referenced by any view
const removed = oldColors.filter(c => !newPaletteRetains(c.index));
const stillUsed = removed.filter(c => used.has(c.index));
if (stillUsed.length) throw new Error(`colors still in use: ${stillUsed.map(c => c.index).join(",")}`);

Try / catch

try { await replacePalette(newColors, order); } catch (e) { const m = String(e).match(/custom color \[(\d+)\] is still in use/); if (m) { remapOrRetain(parseInt(m[1])); retry(); } else { throw e; } }

Prevention

When it happens

Trigger: Calling the replace/set custom colors API with a new palette that drops a color index currently referenced by attribute view cells (usedIndexes contains an index absent from retainedIndexes).

Common situations: Plugin rewriting the palette without first remapping views that use existing colors; user deleting a color while views still point at it; bulk palette import that doesn't carry over in-use colors.

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


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/2eb2d63a7f7815b4. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view.go:8925

	if nil == order {
		order = oldOrder
	}

	retainedIndexes := map[int]struct{}{}
	for _, color := range colors {
		retainedIndexes[color.Index] = struct{}{}
	}
	usedIndexes := map[int]struct{}{}
	for _, index := range attrView.UsedCustomColorIndexes() {
		usedIndexes[index] = struct{}{}
	}
	for _, oldColor := range oldColors {
		if nil == oldColor {
			continue
		}
		if _, retained := retainedIndexes[oldColor.Index]; !retained {
			if _, used := usedIndexes[oldColor.Index]; used {
				return fmt.Errorf("attribute view custom color [%d] is still in use", oldColor.Index)
			}
		}
	}

	if err = replaceWorkspaceAVPalette(colors, order); nil != err {
		return
	}
	ReloadAttrView(attrView.ID)
	for _, relatedAvID := range av.GetSrcAvIDs(attrView.ID) {
		if relatedAvID != attrView.ID {
			ReloadAttrView(relatedAvID)
		}
	}
	return
}

func (tx *Transaction) doRemoveAttrViewColOption(operation *Operation) (ret *TxErr) {
	err := tx.mutateAttributeViewOption(operation, true)

View on GitHub (pinned to 9f775e8a12)