{"record":{"id":"089c179d24b1b40c","repo":"siyuan-note/siyuan","slug":"hidden-builtin-s-index-d-must-be-between-d-an","errorCode":null,"errorMessage":"hidden builtin %s index [%d] must be between %d and %d","messagePattern":"hidden builtin (.+?) index \\[(.+?)\\] must be between (.+?) and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":821,"sourceCode":"\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)\n\t\t}\n\t\tif _, exists := seen[index]; exists {\n\t\t\tcontinue\n\t\t}\n\t\tseen[index] = struct{}{}\n\t\tret = append(ret, index)\n\t}\n\tsort.Ints(ret)\n\treturn ret, nil\n}\n\nfunc normalizeHiddenBuiltinStyleIDs(ids []string) (ret []string, err error) {\n\tseen := make(map[string]struct{}, len(ids))\n\tfor _, value := range ids {\n\t\tid := strings.TrimSpace(value)\n\t\tif _, valid := builtinStyleOrder[id]; !valid {\n\t\t\treturn nil, fmt.Errorf(\"invalid hidden builtin style ID [%s]\", id)","sourceCodeStart":803,"sourceCodeEnd":839,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L803-L839","documentation":"Hidden builtin color indexes are validated against allowed bounds: the global builtin palette index range (minBuiltinColorIndex..maxBuiltinColorIndex), or a smaller range capped at neutralAVColorIndex when the field is \"av\". An index outside the valid range for that field is rejected so hidden-entry configuration cannot reference nonexistent palette colors.","triggerScenarios":"Saving the configuration that lists hidden builtin color indexes (per field, e.g. style colors vs \"av\" attribute-view colors) with an index smaller than minBuiltinColorIndex or larger than the field's max (maxBuiltinColorIndex for styles, neutralAVColorIndex for av).","commonSituations":"Hand-editing conf.json after a palette change; a stale config written by an older SiYuan version whose builtin palette was larger/smaller; a plugin enumerating palette colors by guesswork and passing an off-by-one or oversized index.","solutions":["Check the index against the current builtin palette size and use only indexes between minBuiltinColorIndex and maxBuiltinColorIndex (or neutralAVColorIndex for the \"av\" field)","If the config predates a palette change, regenerate the hidden-index list from the current palette in Settings - Appearance instead of reusing old numbers","For the \"av\" field specifically, cap indexes at neutralAVColorIndex; move larger indexes out of the av list"],"exampleFix":"// before\nhiddenBuiltinColorIndexes: [0, 99]\n// after\nhiddenBuiltinColorIndexes: [1, 5]","handlingStrategy":"validation","validationCode":"function validHiddenIndexes(indexes, isAV) {\n  const max = isAV ? 11 : 25; // match current minBuiltinColorIndex..maxBuiltinColorIndex / neutralAVColorIndex\n  return indexes.every(i => Number.isInteger(i) && i >= 0 && i <= max);\n}","typeGuard":"const isIndexList = v => Array.isArray(v) && v.every(i => Number.isInteger(i));","tryCatchPattern":"try { saveConfig(cfg); } catch (e) { if (String(e).includes(\"must be between\")) { cfg.hiddenBuiltinColorIndexes = cfg.hiddenBuiltinColorIndexes.filter(i => i <= maxIndex); saveConfig(cfg); } }","preventionTips":["Derive the index list from the current palette API instead of hardcoding","Re-validate hidden indexes after upgrading SiYuan versions","Keep the av list and style list separate; av indexes are capped lower"],"tags":["configuration","validation","out-of-range","palette"],"backgroundTag":"value-out-of-range","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"}