chenhg5/cc-connect · error
config: %s.history_max_len must be >= 0
Error message
config: %s.history_max_len must be >= 0
What it means
CC-Connect validates that the display history cap is non-negative at config load time. If `[projects.display].history_max_len` is a negative integer, validateDisplayConfig rejects the config. The value bounds how many history entries are retained/rendered; 0 means unlimited.
Source
Thrown at config/config.go:1094
if display == nil {
return nil
}
if display.Mode != nil {
switch *display.Mode {
case DisplayModeFull, DisplayModeCompact, DisplayModeQuiet:
default:
return fmt.Errorf("config: %s.mode must be \"full\", \"compact\", or \"quiet\"", prefix)
}
}
if display.CardMode != nil {
switch strings.ToLower(strings.TrimSpace(*display.CardMode)) {
case "legacy", "rich":
default:
return fmt.Errorf("config: %s.card_mode must be \"legacy\" or \"rich\"", prefix)
}
}
if display.HistoryMaxLen != nil && *display.HistoryMaxLen < 0 {
return fmt.Errorf("config: %s.history_max_len must be >= 0", prefix)
}
return nil
}
var supportedReferenceAgents = map[string]struct{}{
"all": {},
"codex": {},
"claudecode": {},
}
var supportedReferencePlatforms = map[string]struct{}{
"all": {},
"feishu": {},
"weixin": {},
}
var supportedReferenceDisplayPaths = map[string]struct{}{
"": {},View on GitHub (pinned to 4000b2338a)
Solutions
- Set history_max_len to 0 for unlimited history (it is not a signed sentinel)
- Use a positive integer to cap history entries (e.g. 50)
- Remove the line to fall back to the default
Example fix
# before [projects.display] history_max_len = -1 # after [projects.display] history_max_len = 0
Defensive patterns
Strategy: validation
Validate before calling
if cfg.Projects[i].Display != nil && cfg.Projects[i].Display.HistoryMaxLen != nil && *cfg.Projects[i].Display.HistoryMaxLen < 0 {
return fmt.Errorf("history_max_len must be >= 0")
} Prevention
- Use 0 (not -1) for unlimited history
- Never copy -1 sentinel conventions from other tools
- Sanity-check all numeric display fields are non-negative before deploying
When it happens
Trigger: Loading config.toml with history_max_len set to a negative number, e.g. history_max_len = -1, typically from a misunderstanding that -1 means 'unlimited'.
Common situations: Users porting conventions from other tools where -1 means infinity; sign typo while editing; template configs where a placeholder like -1 was left in.
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
- tmux: 'session' option is required (name of the tmux session
- config: relay.visibility must be "full", "summary", or "none
- config: at least one [[projects]] entry is required
- config: %s.name is required
- config: %s.agent.type is required
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/32d821bc5459a825.
Report an issue: GitHub.