chenhg5/cc-connect · warning

%s must be true or false

Error message

%s must be true or false

What it means

parseCronEditValue validates cron_edit field values; boolean fields (enabled, mute, silent) must parse via strconv.ParseBool. When the user supplies anything other than a Go-acceptable boolean literal, the command returns '<field> must be true or false'.

Source

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

// parseCronEditValue converts the user-supplied <value> argument into the
// concrete Go type the management API's cron-edit handler expects on the wire.
// Bool/int fields must be sent as the matching JSON type so the server's
// updateJobField type-switch (core/cron.go) matches — otherwise the server
// falls through to its string-via-reflection path, which doesn't apply to
// *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{

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Use exactly true/false (also accepted: 1/0, t/f, TRUE/FALSE, True/False)
  2. Trim whitespace from the value before parsing if input comes from free text
  3. Re-run the cron edit command with a valid boolean literal

Example fix

// before
/cron edit <id> enabled=yes
// error: enabled must be true or false

// after
/cron edit <id> enabled=true
Defensive patterns

Strategy: validation

Validate before calling

func isBoolLiteral(s string) bool { _, err := strconv.ParseBool(strings.TrimSpace(s)); return err == nil }
// use before invoking cron edit with enabled/mute/silent

Try / catch

v, err := parseCronEditValue(field, val)
if err != nil {
    return fmt.Errorf("%v; accepted: true/false (also 1/0, t/f, TRUE/FALSE)", err)
}

Prevention

When it happens

Trigger: Running the cron edit command with enabled/mute/silent set to values like 'yes', '1' is accepted but 'on', 'y', 'enable', 'True '? no — accepted values are 1,t,T,TRUE,true,True,0,f,F,FALSE,false,False; anything else (e.g. 'yes', 'on', 'enable') triggers this error.

Common situations: Users typing natural-language booleans ('yes', 'on', 'off' — note 'off' also fails? 'off' is not ParseBool-accepted, so it fails) in a chat message driving /cron edit; locale-cased input like 'TRUE ' with trailing whitespace.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


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