{"record":{"id":"14b435348a92b8d4","repo":"multica-ai/multica","slug":"repo-cache-not-initialized","errorCode":null,"errorMessage":"repo cache not initialized","messagePattern":"repo cache not initialized","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/internal/daemon/health.go","lineNumber":252,"sourceCode":"\t\tif req.URL == \"\" {\n\t\t\thttp.Error(w, \"url is required\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif req.WorkspaceID == \"\" {\n\t\t\thttp.Error(w, \"workspace_id is required\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif req.WorkDir == \"\" {\n\t\t\thttp.Error(w, \"workdir is required\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif req.CheckoutMode != \"\" && req.CheckoutMode != repoCheckoutModeIsolated {\n\t\t\thttp.Error(w, \"invalid checkout_mode\", http.StatusBadRequest)\n\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)","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/health.go#L234-L270","documentation":"Returned as HTTP 500 by the daemon's repo checkout endpoint when the handler needs the shared repository cache (d.repoCache) but it was never constructed. The repo cache is the component that clones/fetches git repositories and manages worktrees; without it no checkout can proceed. It indicates the daemon process came up in a configuration where repository caching was disabled or failed to initialize at startup.","triggerScenarios":"POST to the daemon's repo checkout endpoint (the handler validating workdir/checkout_mode in server/internal/daemon/health.go) while the daemon was started without a repo cache — e.g. a flag/config that disables repo caching, a startup initialization error that left d.repoCache nil, or running a daemon build that intentionally omits the cache.","commonSituations":"Local dev daemon launched with cache disabled; a config regression after upgrading the daemon; a staging daemon whose cache initialization failed silently at boot; tests that spin up the daemon handler struct without wiring a cache.","solutions":["Check the daemon startup flags/config for the option that constructs the repo cache and enable it, then restart the daemon.","Inspect daemon startup logs for a failed repo-cache initialization (bad cache dir, permission error on the cache root) and fix the underlying cause.","If running a custom/embedded daemon, verify the code path that assigns d.repoCache runs before the HTTP handlers are registered.","As a quick diagnostic, hit the daemon health/status endpoint to confirm which subsystems report initialized."],"exampleFix":"// before: daemon started with repo cache disabled\ndaemon.Start(cfg) // cfg.DisableRepoCache = true\n\n// after: enable the repo cache in daemon config\n// before\ncfg.DisableRepoCache = true\n// after\ncfg.DisableRepoCache = false\ndaemon.Start(cfg)","handlingStrategy":"validation","validationCode":"// client: probe daemon readiness before checkout\nresp, _ := http.Get(daemonBase + \"/healthz\")\nif resp.StatusCode != 200 { log.Fatal(\"daemon not ready\") }","typeGuard":null,"tryCatchPattern":"resp, err := client.Do(req)\nif err == nil && resp.StatusCode == 500 && strings.Contains(body, \"repo cache not initialized\") {\n    // server-side config problem: report to operator, do not retry blindly\n}","preventionTips":["Run the daemon with repo caching enabled in any environment that performs checkouts.","Add a startup assertion that fails fast when repo cache initialization errors instead of serving handlers with nil.","Smoke-test the checkout endpoint after daemon deploys."],"tags":["daemon","git","configuration","http-500"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}