chenhg5/cc-connect · error

either prompt or exec is required

Error message

either prompt or exec is required

What it means

handleHook validation: the request carries neither prompt nor exec, so there is nothing to run. Sentinel guard returning HTTP 400; exactly one of the two fields must be non-empty (both set is rejected separately).

Source

Thrown at core/webhook.go:108

	}

	if !ws.authenticate(r) {
		http.Error(w, "unauthorized", http.StatusUnauthorized)
		return
	}

	var req WebhookRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		http.Error(w, "invalid JSON: "+err.Error(), http.StatusBadRequest)
		return
	}

	if req.SessionKey == "" {
		http.Error(w, "session_key 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
	}

	engine, err := ws.resolveEngine(req.Project)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	eventName := req.Event
	if eventName == "" {
		eventName = "webhook"
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Add a non-empty prompt (natural-language instruction) or exec (command) field.
  2. If the action value comes from a variable, check it isn't empty/whitespace before sending.
  3. If you only intended a ping/health check, don't use the hook endpoint for that.

Example fix

// before
{"session_key": "s1"}
// after
{"session_key": "s1", "exec": "go test ./..."}
Defensive patterns

Strategy: validation

Validate before calling

func checkWebhookReq(r WebhookRequest) error {
    if r.Prompt == "" && r.Exec == "" { return errors.New("either prompt or exec is required") }
    return nil
}

Type guard

func hasAction(p map[string]any) bool {
    pr, _ := p["prompt"].(string); ex, _ := p["exec"].(string)
    return pr != "" || ex != ""
}

Try / catch

resp, err := http.Post(url, "application/json", bytes.NewReader(payload))
if err == nil && resp.StatusCode == 400 {
    b, _ := io.ReadAll(resp.Body)
    if strings.Contains(string(b), "either prompt or exec") {
        return errors.New("payload had no action: set prompt or exec")
    }
    return fmt.Errorf("webhook rejected: %s", b)
}

Prevention

When it happens

Trigger: Posting JSON with only session_key (and optional project/event) but no prompt or exec field; both fields present but empty strings.

Common situations: Template or automation building the payload drops the action field when a variable is empty; sending an event-only request that the API doesn't support.

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/200b8f057e73d1ce. Report an issue: GitHub.