multica-ai/multica · error

err.Error()

Error message

err.Error()

What it means

HTTP 500 (or 400 when the error is ErrRepoNotConfigured) returned when ensureRepoReady fails while preparing a repository for checkout. ensureRepoReady clones the repository on first use, fetches updates, and verifies credentials; any failure there (bad URL, unreachable git host, auth rejection, disk error, workspace repo not configured) is surfaced verbatim via err.Error(). The response status is 500 unless the error is exactly ErrRepoNotConfigured, which maps to 400.

Source

Thrown at server/internal/daemon/health.go:266

			return
		}

		if d.repoCache == nil {
			http.Error(w, "repo cache not initialized", http.StatusInternalServerError)
			return
		}

		if err := d.ensureRepoReady(r.Context(), req.WorkspaceID, req.URL); err != nil {
			if r.Context().Err() != nil {
				d.logger.Debug("repo checkout readiness cancelled", "url", req.URL, "error", err)
				return
			}
			statusCode := http.StatusInternalServerError
			if errors.Is(err, ErrRepoNotConfigured) {
				statusCode = http.StatusBadRequest
			}
			d.logger.Error("repo checkout readiness failed", "workspace_id", req.WorkspaceID, "url", req.URL, "error", err)
			http.Error(w, err.Error(), statusCode)
			return
		}

		checkoutRef := strings.TrimSpace(req.Ref)
		if checkoutRef == "" {
			checkoutRef = d.taskRepoDefaultRef(req.WorkspaceID, req.TaskID, req.URL)
		}

		params := repocache.WorktreeParams{
			WorkspaceID:         req.WorkspaceID,
			RepoURL:             req.URL,
			WorkDir:             req.WorkDir,
			Ref:                 checkoutRef,
			AgentName:           req.AgentName,
			TaskID:              req.TaskID,
			CoAuthoredByEnabled: d.workspaceCoAuthoredByEnabled(req.WorkspaceID),
			IsolatedGitMetadata: req.CheckoutMode == repoCheckoutModeIsolated,
		}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Read the response body: the exact error text from ensureRepoReady identifies the failing step (clone vs fetch vs auth).
  2. If the error mentions authentication, refresh the git credentials configured for the workspace/daemon and retry.
  3. If the error is 'repo not configured' (HTTP 400), re-register the repository for the workspace before retrying checkout.
  4. Verify the repo URL is reachable from the daemon host (git ls-remote <url>) and that the cache directory has free space and write permission.
  5. If the request was cancelled client-side, the daemon logs a Debug line instead — check whether your client's timeout is aborting long clones.

Example fix

# before: checkout with a repo the daemon cannot reach
curl -X POST :8080/repo/checkout -d '{"url":"https://git.example.com/org/repo","workdir":"/w"}'
# → 500 "dial tcp: lookup git.example.com: no such host"

# after: verify reachability first, then checkout
git ls-remote https://git.example.com/org/repo
curl -X POST :8080/repo/checkout -d '{"url":"https://git.example.com/org/repo","workdir":"/w"}'
Defensive patterns

Strategy: retry

Validate before calling

// preflight: confirm the repo is reachable and creds work
if err := shell("git ls-remote " + req.URL).Run(); err != nil {
    return fmt.Errorf("repo unreachable, aborting checkout: %w", err)
}

Try / catch

resp, err := client.Do(req)
if err == nil && resp.StatusCode >= 400 {
    body, _ := io.ReadAll(resp.Body)
    if resp.StatusCode == 400 && strings.Contains(string(body), "not configured") {
        // register repo for workspace, then retry once
    }
    // 500: surface body verbatim — it names the failing step (clone/fetch/auth)
}

Prevention

When it happens

Trigger: POST to the daemon repo checkout endpoint with a repo URL that cannot be cloned (DNS failure, 401/403 from the git host, malformed URL), a workspace whose repository record is missing (ErrRepoNotConfigured → 400), or a disk/permission error on the cache directory during clone/fetch.

Common situations: Expired or missing git credentials for a private repo; typos in the repo URL; the git hosting provider is temporarily down or rate-limiting; full disk on the daemon host; the workspace's repo row was deleted between task creation and checkout.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/68a783c97e9ebc59. Report an issue: GitHub.