{"record":{"id":"5fddb2ac6dbdc459","repo":"chenhg5/cc-connect","slug":"s-must-be-true-or-false","errorCode":null,"errorMessage":"%s must be true or false","messagePattern":"(.+?) must be true or false","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/cc-connect/cron.go","lineNumber":575,"sourceCode":"\n// parseCronEditValue converts the user-supplied <value> argument into the\n// concrete Go type the management API's cron-edit handler expects on the wire.\n// Bool/int fields must be sent as the matching JSON type so the server's\n// updateJobField type-switch (core/cron.go) matches — otherwise the server\n// falls through to its string-via-reflection path, which doesn't apply to\n// *bool / *int fields and returns the misleading error\n// \"unknown or invalid field: <field>\".\n//\n// `silent` was previously missing from the bool case here even though it's\n// documented as a bool in printCronEditUsage, so `cc-connect cron edit <id>\n// silent true` failed with \"unknown or invalid field: silent\" — see the\n// regression test in cron_edit_test.go.\nfunc parseCronEditValue(field, valueStr string) (any, error) {\n\tswitch field {\n\tcase \"enabled\", \"mute\", \"silent\":\n\t\tv, err := strconv.ParseBool(valueStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%s must be true or false\", field)\n\t\t}\n\t\treturn v, nil\n\tcase \"timeout_mins\":\n\t\tv, err := strconv.Atoi(valueStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"timeout_mins must be an integer\")\n\t\t}\n\t\treturn v, nil\n\tdefault:\n\t\t// String fields: project, session_key, cron_expr, prompt, exec,\n\t\t// work_dir, description, session_mode, mode\n\t\treturn valueStr, nil\n\t}\n}\n\nfunc apiPost(sockPath, path string, payload []byte) (*http.Response, error) {\n\tclient := &http.Client{\n\t\tTransport: &http.Transport{","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/cron.go#L557-L593","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use exactly true/false (also accepted: 1/0, t/f, TRUE/FALSE, True/False)","Trim whitespace from the value before parsing if input comes from free text","Re-run the cron edit command with a valid boolean literal"],"exampleFix":"// before\n/cron edit <id> enabled=yes\n// error: enabled must be true or false\n\n// after\n/cron edit <id> enabled=true","handlingStrategy":"validation","validationCode":"func isBoolLiteral(s string) bool { _, err := strconv.ParseBool(strings.TrimSpace(s)); return err == nil }\n// use before invoking cron edit with enabled/mute/silent","typeGuard":null,"tryCatchPattern":"v, err := parseCronEditValue(field, val)\nif err != nil {\n    return fmt.Errorf(\"%v; accepted: true/false (also 1/0, t/f, TRUE/FALSE)\", err)\n}","preventionTips":["Use only true/false in cron edit commands","Trim user-supplied values before parsing","Validate boolean fields client-side before sending the command","Map 'yes'/'on' to true in any chat-input preprocessing"],"tags":["go","cli","validation","cron"],"backgroundTag":"invalid-flag-value","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}