{"record":{"id":"323306aca5682dee","repo":"multica-ai/multica","slug":"encode-request-w","errorCode":null,"errorMessage":"encode request: %w","messagePattern":"encode request: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/cmd/multica/cmd_repo.go","lineNumber":366,"sourceCode":"\tworkDir, err := os.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get working directory: %w\", err)\n\t}\n\n\treqBody := map[string]any{\n\t\t\"url\":           repoURL,\n\t\t\"workspace_id\":  workspaceID,\n\t\t\"workdir\":       workDir,\n\t\t\"ref\":           repoCheckoutRef,\n\t\t\"agent_name\":    agentName,\n\t\t\"task_id\":       taskID,\n\t\t\"checkout_mode\": strings.TrimSpace(os.Getenv(\"MULTICA_REPO_CHECKOUT_MODE\")),\n\t\t\"retry_busy\":    true,\n\t}\n\n\tdata, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"encode request: %w\", err)\n\t}\n\n\tparentCtx := cmd.Context()\n\tif parentCtx == nil {\n\t\tparentCtx = context.Background()\n\t}\n\tctx, cancel := context.WithTimeout(parentCtx, 5*time.Minute)\n\tdefer cancel()\n\tclient := &http.Client{}\n\tcheckoutURL := fmt.Sprintf(\"http://127.0.0.1:%s/repo/checkout\", daemonPort)\n\tvar body []byte\n\tfor {\n\t\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, checkoutURL, bytes.NewReader(data))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"create daemon checkout request: %w\", err)\n\t\t}\n\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\t\tresp, err := client.Do(req)","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_repo.go#L348-L384","documentation":"runRepoCheckout wraps json.Marshal(reqBody) where reqBody is a map[string]any built only from strings, an int-shaped bool literal, and strings.TrimSpace results. Marshaling a map of primitive values cannot fail in practice — all values (strings and the bool true) are marshal-safe — so this error is effectively unreachable defensive code.","triggerScenarios":"Theoretically only if reqBody ever gained a channel, function, or complex value in a future edit; with the current body ({url, workspace_id, workdir, ref, agent_name, task_id, checkout_mode, retry_busy:true}) it cannot trigger.","commonSituations":"None in the current code; would appear only after someone adds a non-marshalable value (chan, func, complex, or a struct with unsupported fields) to reqBody.","solutions":["If you genuinely hit this in a modified build, inspect reqBody for non-serializable values (channels/functions) added by your patch.","For maintainers: values are all string/bool, so this branch can be simplified or asserted away."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// guard the map before marshal if extending reqBody\nfunc marshalSafe(v any) bool {\n\tswitch v.(type) {\n\tcase string, bool, int, int64, float64, nil:\n\t\treturn true\n\t}\n\treturn false\n}\nfor _, v := range reqBody {\n\tif !marshalSafe(v) { return fmt.Errorf(\"non-serializable field in request body\") }\n}","tryCatchPattern":null,"preventionTips":["Keep reqBody limited to string/bool values; never insert chan/func/complex.","Consider a typed struct instead of map[string]any so the compiler enforces marshalability."],"tags":["go","json","unreachable","defensive-code"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}