chenhg5/cc-connect · error
log size: empty value
Error message
log size: empty value
What it means
ParseLogSize input guard: the log size value is empty after trimming, so no byte size can be derived. Accepted forms are raw byte counts or K/M/G (short or KB/MB/GB, case-insensitive) with binary 1024-based multipliers; empty, negative, or unknown-suffix values are rejected.
Source
Thrown at daemon/logsize.go:23
"strconv"
"strings"
)
// ParseLogSize converts a human-friendly byte size string (e.g. "10MB",
// "512K", "1G", or a raw byte count) into a byte count. Suffixes are
// case-insensitive and may be followed by optional whitespace. Both the SI
// short forms (K, M, G) and the long forms (KB, MB, GB) are accepted and
// always use the binary (1024-based) multiplier — matching what users see
// in editor "file size" columns and the existing DefaultLogMaxSize comment
// of "10 MB".
//
// Returns an error if the input is empty, negative, has an unknown suffix,
// or cannot be parsed as an integer.
func ParseLogSize(s string) (int64, error) {
orig := s
s = strings.TrimSpace(s)
if s == "" {
return 0, fmt.Errorf("log size: empty value")
}
// Walk from the end of the string. Suffix is one of the documented forms
// (K, KB, M, MB, G, GB, T, TB). Comparison is case-insensitive — the
// long forms are tried first so e.g. "10MB" matches "MB" rather than
// falling through to the bare "B" branch. The numeric part is parsed
// verbatim, so a stray "10XYZ" fails loudly rather than silently
// downgrading to a 10-byte log.
upper := strings.ToUpper(s)
var multiplier int64 = 1
var numPart string
switch {
case strings.HasSuffix(upper, "TB"):
multiplier = 1024 * 1024 * 1024 * 1024
numPart = s[:len(s)-len("TB")]
case strings.HasSuffix(upper, "T"):
multiplier = 1024 * 1024 * 1024 * 1024
numPart = s[:len(s)-len("T")]View on GitHub (pinned to 4000b2338a)
Solutions
- Set a concrete size value, e.g. "100MB" or "52428800".
- If the value comes from an env var, give it a non-empty value or unset it so the default applies.
- Add a default in the config resolution layer for empty input instead of passing it through.
Example fix
// before (shell) export CC_CONNECT_LOG_SIZE= // after export CC_CONNECT_LOG_SIZE=100MB
Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(cfg.LogMaxSize) == "" {
return fmt.Errorf("log_max_size is required and must be non-empty, e.g. \"100MB\"")
} Try / catch
size, err := daemon.ParseLogSize(s)
if err != nil {
if strings.Contains(err.Error(), "empty value") {
size = defaultLogSize // apply a documented default
}
return err
} Prevention
- Always give the size key a value in config.toml; remove the key entirely if you want the default.
- Guard env vars: treat empty as unset (`[ -n "$VAR" ]`).
- Validate config at startup with clear field-level messages.
When it happens
Trigger: Calling ParseLogSize (directly or via resolveLogMaxSize/main) with "" or a whitespace-only string such as " ".
Common situations: Missing config.toml key read as empty string; env var like CC_CONNECT_LOG_SIZE defined but empty (`export CC_CONNECT_LOG_SIZE=`); template rendering leaving a blank value.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 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/c9e1b91d96224e1c.
Report an issue: GitHub.