{"record":{"id":"68a783c97e9ebc59","repo":"multica-ai/multica","slug":"err-error","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/internal/daemon/health.go","lineNumber":266,"sourceCode":"\t\t\treturn\n\t\t}\n\n\t\tif d.repoCache == nil {\n\t\t\thttp.Error(w, \"repo cache not initialized\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tif err := d.ensureRepoReady(r.Context(), req.WorkspaceID, req.URL); err != nil {\n\t\t\tif r.Context().Err() != nil {\n\t\t\t\td.logger.Debug(\"repo checkout readiness cancelled\", \"url\", req.URL, \"error\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tstatusCode := http.StatusInternalServerError\n\t\t\tif errors.Is(err, ErrRepoNotConfigured) {\n\t\t\t\tstatusCode = http.StatusBadRequest\n\t\t\t}\n\t\t\td.logger.Error(\"repo checkout readiness failed\", \"workspace_id\", req.WorkspaceID, \"url\", req.URL, \"error\", err)\n\t\t\thttp.Error(w, err.Error(), statusCode)\n\t\t\treturn\n\t\t}\n\n\t\tcheckoutRef := strings.TrimSpace(req.Ref)\n\t\tif checkoutRef == \"\" {\n\t\t\tcheckoutRef = d.taskRepoDefaultRef(req.WorkspaceID, req.TaskID, req.URL)\n\t\t}\n\n\t\tparams := repocache.WorktreeParams{\n\t\t\tWorkspaceID:         req.WorkspaceID,\n\t\t\tRepoURL:             req.URL,\n\t\t\tWorkDir:             req.WorkDir,\n\t\t\tRef:                 checkoutRef,\n\t\t\tAgentName:           req.AgentName,\n\t\t\tTaskID:              req.TaskID,\n\t\t\tCoAuthoredByEnabled: d.workspaceCoAuthoredByEnabled(req.WorkspaceID),\n\t\t\tIsolatedGitMetadata: req.CheckoutMode == repoCheckoutModeIsolated,\n\t\t}","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/health.go#L248-L284","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the response body: the exact error text from ensureRepoReady identifies the failing step (clone vs fetch vs auth).","If the error mentions authentication, refresh the git credentials configured for the workspace/daemon and retry.","If the error is 'repo not configured' (HTTP 400), re-register the repository for the workspace before retrying checkout.","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.","If the request was cancelled client-side, the daemon logs a Debug line instead — check whether your client's timeout is aborting long clones."],"exampleFix":"# before: checkout with a repo the daemon cannot reach\ncurl -X POST :8080/repo/checkout -d '{\"url\":\"https://git.example.com/org/repo\",\"workdir\":\"/w\"}'\n# → 500 \"dial tcp: lookup git.example.com: no such host\"\n\n# after: verify reachability first, then checkout\ngit ls-remote https://git.example.com/org/repo\ncurl -X POST :8080/repo/checkout -d '{\"url\":\"https://git.example.com/org/repo\",\"workdir\":\"/w\"}'","handlingStrategy":"retry","validationCode":"// preflight: confirm the repo is reachable and creds work\nif err := shell(\"git ls-remote \" + req.URL).Run(); err != nil {\n    return fmt.Errorf(\"repo unreachable, aborting checkout: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.Do(req)\nif err == nil && resp.StatusCode >= 400 {\n    body, _ := io.ReadAll(resp.Body)\n    if resp.StatusCode == 400 && strings.Contains(string(body), \"not configured\") {\n        // register repo for workspace, then retry once\n    }\n    // 500: surface body verbatim — it names the failing step (clone/fetch/auth)\n}","preventionTips":["Keep git credentials for private repos configured and rotated before expiry.","Run git ls-remote as a cheap preflight before checkout requests.","Monitor daemon cache disk space."],"tags":["daemon","git","clone","http-500","credentials"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}