chenhg5/cc-connect · error

err.Error()

Error message

err.Error()

What it means

`ws.resolveEngine(req.Project)` failed — the requested project could not be mapped to a running engine — and its error text is returned verbatim with 400. This typically means the project name in the payload doesn't match any configured/registered project.

Source

Thrown at core/webhook.go:118

		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"
	}

	slog.Info("webhook: received",
		"event", eventName,
		"project", req.Project,
		"session_key", req.SessionKey,
		"has_prompt", req.Prompt != "",
		"has_exec", req.Exec != "",
	)

	if req.Exec != "" {
		go ws.executeShell(engine, req, eventName)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Use the exact project name from config.toml / engine registration (check case).
  2. Omit the project field if you run a single project and no default is required.
  3. Verify the engine for that project started successfully before sending webhooks.
  4. Inspect resolveEngine to confirm how project names are keyed and match accordingly.

Example fix

// before
{"session_key":"s1","prompt":"hi","project":"myapp"}   // config has [projects.my-app]
// after
{"session_key":"s1","prompt":"hi","project":"my-app"}
Defensive patterns

Strategy: validation

Validate before calling

var knownProjects = map[string]bool{"my-app": true}
func checkProject(p string) error {
    if p != "" && !knownProjects[p] { return fmt.Errorf("unknown project %q", p) }
    return nil
}

Type guard

func isProjectNotFound(resp *http.Response) bool {
    if resp == nil || resp.StatusCode != 400 { return false }
    b, _ := io.ReadAll(resp.Body)
    return strings.Contains(strings.ToLower(string(b)), "project")
}

Try / catch

resp, err := http.Post(url, "application/json", bytes.NewReader(payload))
if err == nil && resp.StatusCode == 400 {
    b, _ := io.ReadAll(resp.Body)
    return fmt.Errorf("resolveEngine rejected project: %s", b) // body carries the reason
}

Prevention

When it happens

Trigger: req.Project set to a name not present in the webhook server's project registry; empty project when no default project is configured; project service not yet started when the request arrives.

Common situations: Typo in the project name (case-sensitive mismatch); config.toml lists a project the server doesn't register; sending project for a single-project deployment that ignores it.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — 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/d407ce7bcc251ab6. Report an issue: GitHub.