{"record":{"id":"f41a442db268c29d","repo":"siyuan-note/siyuan","slug":"attribute-view-custom-color-d-is-still-in-use-b","errorCode":null,"errorMessage":"attribute view custom color [%d] is still in use by attribute view [%s]","messagePattern":"attribute view custom color \\[(.+?)\\] is still in use by attribute view \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":271,"sourceCode":"\t\tVersion: InlineStylesVersion,\n\t\tStyles:  normalizedStyles,\n\t\tBuiltin: normalizedBuiltin,\n\t\tOrder:   normalizeInlineStyleOrder(styles.Order, normalizedStyles),\n\t\tAV:      normalizedAV,\n\t}\n\tchangedCustomColorIndexes := changedAttributeViewCustomColorIndexes(currentAV.Colors, ret.AV.Colors)\n\tvar customColorUsage map[string]map[int]struct{}\n\tif 0 < len(changedCustomColorIndexes) {\n\t\tremovedIndexes := removedAttributeViewCustomColorIndexes(currentAV.Colors, ret.AV.Colors)\n\t\tcustomColorUsage, err = workspaceAttributeViewCustomColorUsage(0 < len(removedIndexes))\n\t\tif err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\tfor _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {\n\t\t\tindexes := customColorUsage[avID]\n\t\t\tfor index := range removedIndexes {\n\t\t\t\tif _, used := indexes[index]; used {\n\t\t\t\t\treturn nil, false, fmt.Errorf(\"attribute view custom color [%d] is still in use by attribute view [%s]\",\n\t\t\t\t\t\tindex, avID)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tdata, err := gulu.JSON.MarshalIndentJSON(ret, \"\", \"  \")\n\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"marshal inline styles failed: %w\", err)\n\t}\n\tif maxInlineStylesFileSize < len(data) {\n\t\treturn nil, false, fmt.Errorf(\"inline styles file exceeds the %d byte limit\", maxInlineStylesFileSize)\n\t}\n\n\tdataPath := inlineStylesPath()\n\toldData, readErr := filelock.ReadFile(dataPath)\n\tif readErr != nil && !os.IsNotExist(readErr) {\n\t\treturn nil, false, fmt.Errorf(\"read inline styles failed: %w\", readErr)\n\t}","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L253-L289","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before removing palette colors, list attribute views and confirm the index is unused:\n// usage := map[string]map[int]bool{} // avID -> color indexes in use\n// if usage[avID][removedIndex] { defer removal }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"is still in use by attribute view\") {\n    // parse avID from the message, update its cells, then retry\n}","preventionTips":["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"],"tags":["attribute-view","conflict","inline-styles"],"backgroundTag":"invalid-state-transition","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}