siyuan-note/siyuan · error
hidden builtin index [ ] must be between and
Error message
hidden builtin %s index [%d] must be between %d and %d
What it means
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.
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
Example fix
// before hiddenBuiltinColorIndexes: [0, 99] // after hiddenBuiltinColorIndexes: [1, 5]
Defensive patterns
Strategy: validation
Validate before calling
function validHiddenIndexes(indexes, isAV) {
const max = isAV ? 11 : 25; // match current minBuiltinColorIndex..maxBuiltinColorIndex / neutralAVColorIndex
return indexes.every(i => Number.isInteger(i) && i >= 0 && i <= max);
} Type guard
const isIndexList = v => Array.isArray(v) && v.every(i => Number.isInteger(i));
Try / catch
try { saveConfig(cfg); } catch (e) { if (String(e).includes("must be between")) { cfg.hiddenBuiltinColorIndexes = cfg.hiddenBuiltinColorIndexes.filter(i => i <= maxIndex); saveConfig(cfg); } } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- cannot save incomplete notebook crypto configuration
- Conf.Language(249)
- ErrInvalidMode
- invalid hidden builtin style ID
- OIDC issuer URL is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/089c179d24b1b40c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:821
if !lightColor && !lightBackground {
return nil, nil, fmt.Errorf("%s must define color or backgroundColor", description)
}
if lightColor != darkColor || lightBackground != darkBackground {
return nil, nil, fmt.Errorf("%s must use the same fields in light and dark themes", description)
}
return normalizedLight, normalizedDark, nil
}
func normalizeHiddenBuiltinColorIndexes(indexes []int, field string) (ret []int, err error) {
ret = make([]int, 0, len(indexes))
seen := make(map[int]struct{}, len(indexes))
maxIndex := maxBuiltinColorIndex
if field == "av" {
maxIndex = neutralAVColorIndex
}
for _, index := range indexes {
if index < minBuiltinColorIndex || maxIndex < index {
return nil, fmt.Errorf("hidden builtin %s index [%d] must be between %d and %d", field, index,
minBuiltinColorIndex, maxIndex)
}
if _, exists := seen[index]; exists {
continue
}
seen[index] = struct{}{}
ret = append(ret, index)
}
sort.Ints(ret)
return ret, nil
}
func normalizeHiddenBuiltinStyleIDs(ids []string) (ret []string, err error) {
seen := make(map[string]struct{}, len(ids))
for _, value := range ids {
id := strings.TrimSpace(value)
if _, valid := builtinStyleOrder[id]; !valid {
return nil, fmt.Errorf("invalid hidden builtin style ID [%s]", id)View on GitHub (pinned to 9f775e8a12)