chenhg5/cc-connect · error

either prompt or exec is required

Error message

either prompt or exec is required

What it means

handleCronAdd validates cron-job creation requests in the HTTP API. A cron job must be driven by either a natural-language prompt or an exec command; the server rejects requests that carry neither, preventing creation of a job that would do nothing when fired.

Source

Thrown at core/api.go:351

		http.Error(w, "POST only", http.StatusMethodNotAllowed)
		return
	}
	if s.cron == nil {
		http.Error(w, "cron scheduler not available", http.StatusServiceUnavailable)
		return
	}

	var req CronAddRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		http.Error(w, "invalid JSON: "+err.Error(), http.StatusBadRequest)
		return
	}
	if req.CronExpr == "" {
		http.Error(w, "cron_expr is required", http.StatusBadRequest)
		return
	}
	if req.Prompt == "" && req.Exec == "" {
		http.Error(w, "either prompt or exec is required", http.StatusBadRequest)
		return
	}
	if req.Prompt != "" && req.Exec != "" {
		http.Error(w, "prompt and exec are mutually exclusive", http.StatusBadRequest)
		return
	}

	// Resolve project: use provided, or pick single engine
	project := req.Project
	if project == "" {
		s.mu.RLock()
		if len(s.engines) == 1 {
			for name := range s.engines {
				project = name
			}
		}
		s.mu.RUnlock()
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Add a non-empty "prompt" (for agent-driven jobs) OR "exec" (for shell commands) to the request JSON
  2. Check the client code that builds the body — an empty variable is likely being serialized as "" and omitted downstream
  3. Confirm you are not sending both later; note prompt and exec are mutually exclusive (next validation)
  4. Inspect the response of a prior step that was supposed to supply the prompt/exec value

Example fix

// before
{"cron_expr": "0 9 * * *"}
// after
{"cron_expr": "0 9 * * *", "prompt": "summarize open issues"}
Defensive patterns

Strategy: validation

Validate before calling

const body = { cron_expr: expr, prompt, exec };
if (!body.prompt && !body.exec) throw new Error('cron job needs a prompt or exec');
if (body.prompt && body.exec) throw new Error('prompt and exec are mutually exclusive');

Type guard

function hasCronAction(b) { return (typeof b?.prompt === 'string' && b.prompt.length > 0) || (typeof b?.exec === 'string' && b.exec.length > 0); }

Prevention

When it happens

Trigger: POST to the cron-add endpoint where req.Prompt == "" and req.Exec == "" (both omitted or empty strings) while cron_expr is present.

Common situations: Clients building the JSON body dynamically omit both fields when a variable is empty; tooling sends only {"cron_expr": "0 9 * * *"}; copy-pasted curl examples drop the prompt field.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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