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

  1. Set history_max_len to 0 for unlimited history (it is not a signed sentinel)
  2. Use a positive integer to cap history entries (e.g. 50)
  3. 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

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


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/32d821bc5459a825. Report an issue: GitHub.