{"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":"exception","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/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L803-L839","documentation":"Hidden built-in inline styles are referenced by numeric color-index values. Each index must fall within the allowed range: the generic built-in range is [minBuiltinColorIndex, maxBuiltinColorIndex], but when the field is \"av\" (attribute view) the upper bound is tightened to neutralAVColorIndex. Any out-of-range index in the hidden list aborts normalization.","triggerScenarios":"Saving a hidden builtin style/color configuration (normalizeHiddenBuiltinColorIndexes in kernel/model/inline_style.go) with a negative index, an index above maxBuiltinColorIndex, or any index above neutralAVColorIndex when field == \"av\".","commonSituations":"Plugin or script storing raw array positions instead of the documented builtin color indexes; configs copied from an older version whose index space differed; users manually editing conf JSON and typos in the index.","solutions":["Clamp or validate each index to [minBuiltinColorIndex, maxBuiltinColorIndex] before saving (for \"av\", to neutralAVColorIndex).","Filter the incoming list against the current builtin color table so stale indexes from older versions are dropped instead of failing the save.","Check the config file for typos in the hidden-index arrays."],"exampleFix":"// before\nindexes := []int{-1, 3, 99}\nconf.HiddenColorIndexes = indexes\n// after\nindexes := []int{-1, 3, 99}\nvalid := []int{}\nfor _, i := range indexes {\n  if i >= minBuiltinColorIndex && i <= maxBuiltinColorIndex {\n    valid = append(valid, i)\n  }\n}\nconf.HiddenColorIndexes = valid","handlingStrategy":"validation","validationCode":"function isValidHiddenIndex(i, isAV) {\n  return Number.isInteger(i) && i >= 0 && i <= (isAV ? 9 : 25); // bounds per builtin color table\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive hidden indexes from the exported builtin color constants, never hardcode numbers.","Filter out-of-range indexes defensively before saving config.","Re-validate stored indexes after upgrading SiYuan versions."],"tags":["validation","range-check","inline-style","config"],"backgroundTag":"value-out-of-range","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}