plandex-ai/plandex · error
Error encoding custom providers: %v
Error message
Error encoding custom providers: %v
What it means
After listing providers and converting them with ToApi(), the handler encodes the response with json.NewEncoder(w).Encode(apiList). If encoding fails (response writer broken, encoding error), it logs 'Error encoding custom providers' and returns HTTP 500.
Source
Thrown at app/server/handlers/models.go:456
http.Error(w, "Custom model providers are not supported on Plandex Cloud", http.StatusBadRequest)
return
}
list, err := db.ListCustomProviders(auth.OrgId)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
var apiList []*shared.CustomProvider
for _, p := range list {
apiList = append(apiList, p.ToApi())
}
err = json.NewEncoder(w).Encode(apiList)
if err != nil {
log.Printf("Error encoding custom providers: %v\n", err)
http.Error(w, fmt.Sprintf("Error encoding custom providers: %v", err), http.StatusInternalServerError)
return
}
log.Println("Successfully fetched custom providers")
}
func CreateModelPackHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Received request for CreateModelPackHandler")
auth := Authenticate(w, r, true)
if auth == nil {
return
}
if !requireMinClientVersion(w, r, CustomModelsMinClientVersion) {
return
}
View on GitHub (pinned to e2d772072e)
Solutions
- Retry the request; this is usually a transient client/connection failure.
- Check the server log for the '%v' detail to confirm the actual encoding error.
- Ensure the client keeps the connection open until the response completes (raise timeout).
- Verify shared.CustomProvider.ToApi() output contains only JSON-serializable fields.
Example fix
// before: double-writes status if headers already sent
err = json.NewEncoder(w).Encode(apiList)
if err != nil {
http.Error(w, fmt.Sprintf("Error encoding custom providers: %v", err), http.StatusInternalServerError)
}
// after: guard with content type and log-only when headers sent
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(apiList); err != nil {
log.Printf("Error encoding custom providers: %v\n", err)
} Defensive patterns
Strategy: retry
Try / catch
resp, err := client.Get(url)
if err != nil { return err }
if resp.StatusCode == 500 {
// often a mid-response disconnect; safe to retry with backoff
return retryWithBackoff(3, 500*time.Millisecond)
}
json.NewDecoder(resp.Body).Decode(&apiList) Prevention
- Use client HTTP timeouts long enough to receive full responses.
- Avoid cancelling requests mid-stream (no fire-and-forget contexts).
- Check server logs for the 'Error encoding custom providers' detail when it recurs.
When it happens
Trigger: json.NewEncoder(w).Encode(apiList) returns an error — typically the client disconnected before the body was written, the ResponseWriter is in a bad state, or an apiList value fails to serialize.
Common situations: Clients aborting the request mid-response (network flake, short HTTP timeout, load-balancer health checks closing connections); large provider lists exceeding client timeouts.
Related errors
- Error marshalling branches:
- Error marshalling response:
- Error marshalling invites:
- Error marshalling response
- Error marshalling contexts:
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/1dc618ced9568b8e.
Report an issue: GitHub.