chenhg5/cc-connect · error

timeout_mins must be an integer

Error message

timeout_mins must be an integer

What it means

parseCronEditValue validates values passed to `cc-connect cron edit`. For the timeout_mins field it calls strconv.Atoi and throws this error when the string is not a valid integer. It exists so that a session timeout given in minutes is always a whole number of minutes, catching typos like 'abc', '10m', '3.5', or empty strings before they reach cron scheduling.

Source

Thrown at cmd/cc-connect/cron.go:581

// *bool / *int fields and returns the misleading error
// "unknown or invalid field: <field>".
//
// `silent` was previously missing from the bool case here even though it's
// documented as a bool in printCronEditUsage, so `cc-connect cron edit <id>
// silent true` failed with "unknown or invalid field: silent" — see the
// regression test in cron_edit_test.go.
func parseCronEditValue(field, valueStr string) (any, error) {
	switch field {
	case "enabled", "mute", "silent":
		v, err := strconv.ParseBool(valueStr)
		if err != nil {
			return nil, fmt.Errorf("%s must be true or false", field)
		}
		return v, nil
	case "timeout_mins":
		v, err := strconv.Atoi(valueStr)
		if err != nil {
			return nil, fmt.Errorf("timeout_mins must be an integer")
		}
		return v, nil
	default:
		// String fields: project, session_key, cron_expr, prompt, exec,
		// work_dir, description, session_mode, mode
		return valueStr, nil
	}
}

func apiPost(sockPath, path string, payload []byte) (*http.Response, error) {
	client := &http.Client{
		Transport: &http.Transport{
			DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
				return net.Dial("unix", sockPath)
			},
		},
	}
	return client.Post("http://unix"+path, "application/json", bytes.NewReader(payload))

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Pass a plain integer number of minutes, e.g. timeout_mins 30
  2. Strip unit suffixes and quotes from the value before invoking the command
  3. Compute the value in minutes in the calling script (e.g. $((hours*60)))

Example fix

// before
cc-connect cron edit c1 timeout_mins 30m
// after
cc-connect cron edit c1 timeout_mins 30
Defensive patterns

Strategy: validation

Validate before calling

func validTimeoutMins(v string) bool { _, err := strconv.Atoi(strings.TrimSpace(v)); return err == nil }

Prevention

When it happens

Trigger: Running `cc-connect cron edit <id> timeout_mins 10m` (unit suffix not allowed), `... timeout_mins 3.5` (decimals rejected), `... timeout_mins ""` (empty), or any non-numeric value such as `abc`.

Common situations: Users type durations the way they write them elsewhere ('30m', '1h'), paste values with quotes or whitespace from config files, or leave the value empty in scripts.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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