chenhg5/cc-connect · error
unknown or invalid field: %s
Error message
unknown or invalid field: %s
What it means
updateJobField resolves the requested field name by converting snake_case to a Go exported field name via reflection; if no settable string field matches (or the field is not a string kind), it returns 'unknown or invalid field'. UpdateJob funnels generic field edits through this helper.
Source
Thrown at core/cron.go:388
n := int(v)
job.TimeoutMins = &n
return nil
}
if v, ok := value.(int); ok {
job.TimeoutMins = &v
return nil
}
}
// Fallback: try to set string field via reflection
if v, ok := value.(string); ok {
rv := reflect.ValueOf(job).Elem()
f := rv.FieldByName(toExportedFieldName(field))
if f.IsValid() && f.Kind() == reflect.String && f.CanSet() {
f.SetString(v)
return nil
}
}
return fmt.Errorf("unknown or invalid field: %s", field)
}
// toExportedFieldName converts snake_case to Go exported field name (e.g., "session_key" -> "SessionKey")
func toExportedFieldName(s string) string {
result := make([]byte, 0, len(s))
upperNext := true
for i := 0; i < len(s); i++ {
c := s[i]
if c == '_' {
upperNext = true
continue
}
if upperNext {
if c >= 'a' && c <= 'z' {
c -= 32
}
upperNext = false
}View on GitHub (pinned to 4000b2338a)
Solutions
- Use one of the supported field names exactly, e.g. cron_expr, mode, session_key, session_mode, enabled, prompt.
- Check the CronJob struct definition for the exact exported field spelling.
- For non-string fields (timeout_mins, enabled), use the dedicated typed handling in UpdateJob rather than the generic path.
Example fix
// before sched.UpdateJob(id, "cronexpr", "0 9 * * *") // after sched.UpdateJob(id, "cron_expr", "0 9 * * *")
Defensive patterns
Strategy: validation
Validate before calling
var allowedFields = map[string]bool{"cron_expr":true,"mode":true,"session_mode":true,"session_key":true,"prompt":true,"enabled":true}
if !allowedFields[field] { return fmt.Errorf("unsupported field %q", field) } Prevention
- Keep an allowlist of editable field names in the UI/client.
- Copy field names from the CronJob struct or docs verbatim.
- Use snake_case exactly as the API expects.
When it happens
Trigger: CronScheduler.UpdateJob(id, "field", value) where `field` does not map to any CronJob exported field (after snake_case→CamelCase conversion), or maps to a non-string/ non-settable field such as an int, bool, or unexported field.
Common situations: Typo in field name from a /cron edit command (e.g. 'cronexpr' instead of 'cron_expr', 'namee'); API clients attempting to set numeric fields like timeout_mins through the generic string-set path.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- %s must be true or false
- timeout_mins must be >= 0
- invalid cron expression %q: %w
- job %q not found
- cron_expr must be a string
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/d884d190c1b1944a.
Report an issue: GitHub.