{"record":{"id":"803fcfdba2bdeff0","repo":"siyuan-note/siyuan","slug":"s-must-define-color-or-backgroundcolor","errorCode":null,"errorMessage":"%s must define color or backgroundColor","messagePattern":"(.+?) must define color or backgroundColor","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":804,"sourceCode":"\tret.Order = av.NormalizeAttributeViewColorOrder(palette.Order, colors)\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleThemePair(light, dark *InlineStyleTheme, description string) (normalizedLight,\n\tnormalizedDark *InlineStyleTheme, err error) {\n\tif light == nil || dark == nil {\n\t\treturn nil, nil, fmt.Errorf(\"%s must define light and dark themes\", description)\n\t}\n\tif normalizedLight, err = normalizeInlineStyleTheme(light); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid light theme of %s: %w\", description, err)\n\t}\n\tif normalizedDark, err = normalizeInlineStyleTheme(dark); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid dark theme of %s: %w\", description, err)\n\t}\n\tlightColor, lightBackground := normalizedLight.Color != \"\", normalizedLight.BackgroundColor != \"\"\n\tdarkColor, darkBackground := normalizedDark.Color != \"\", normalizedDark.BackgroundColor != \"\"\n\tif !lightColor && !lightBackground {\n\t\treturn nil, nil, fmt.Errorf(\"%s must define color or backgroundColor\", description)\n\t}\n\tif lightColor != darkColor || lightBackground != darkBackground {\n\t\treturn nil, nil, fmt.Errorf(\"%s must use the same fields in light and dark themes\", description)\n\t}\n\treturn normalizedLight, normalizedDark, nil\n}\n\nfunc normalizeHiddenBuiltinColorIndexes(indexes []int, field string) (ret []int, err error) {\n\tret = make([]int, 0, len(indexes))\n\tseen := make(map[int]struct{}, len(indexes))\n\tmaxIndex := maxBuiltinColorIndex\n\tif field == \"av\" {\n\t\tmaxIndex = neutralAVColorIndex\n\t}\n\tfor _, index := range indexes {\n\t\tif index < minBuiltinColorIndex || maxIndex < index {\n\t\t\treturn nil, fmt.Errorf(\"hidden builtin %s index [%d] must be between %d and %d\", field, index,\n\t\t\t\tminBuiltinColorIndex, maxIndex)","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L786-L822","documentation":"A builtin color or builtin style defines neither `color` nor `backgroundColor` in its light theme (and by symmetry the entry is visually empty). Each builtin entry must set at least one of the two fields in both light and dark themes; an entry that sets nothing has no rendering effect, so normalizeInlineStyleThemePair rejects it. The description names the offending entry.","triggerScenarios":"setInlineStylesData or loadInlineStyles with a builtin entry whose light and dark theme objects are both empty or omit both color and backgroundColor, e.g. `{\"index\": 7, \"light\": {}, \"dark\": {}}`.","commonSituations":"Creating a placeholder entry intending to fill values later; a UI/form that cleared both fields but still saved; stripping fields with a sanitizer that removed \"empty\" values.","solutions":["Set a color or backgroundColor (as #rrggbb hex) in both the light and dark themes of the entry named in the message.","If the entry is not needed, remove it from the builtin array entirely.","Add a save-time check that each entry has at least one non-empty theme field in both modes."],"exampleFix":"// before\n{\"index\": 7, \"light\": {}, \"dark\": {}}\n// after\n{\"index\": 7, \"light\": {\"backgroundColor\": \"#fbe9e7\"}, \"dark\": {\"backgroundColor\": \"#4a2b27\"}}","handlingStrategy":"validation","validationCode":"for (const entry of entries) {\n  for (const mode of [\"light\", \"dark\"]) {\n    const t = entry[mode];\n    if (!(t.color || t.backgroundColor)) {\n      throw new Error(`${describe(entry)} ${mode} theme must define color or backgroundColor`);\n    }\n  }\n}","typeGuard":"function hasVisibleTheme(t) {\n  return typeof t.color === \"string\" && t.color !== \"\" || typeof t.backgroundColor === \"string\" && t.backgroundColor !== \"\";\n}","tryCatchPattern":null,"preventionTips":["Do not save placeholder entries with empty theme objects; remove them until real values exist.","Require at least one non-empty theme field per mode in whatever UI or script edits builtin entries."],"tags":["go","configuration","inline-styles","missing-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}