{"record":{"id":"e24aa3cbc19ae464","repo":"docker/compose","slug":"unexpected-status-code-d","errorCode":null,"errorMessage":"unexpected status code: %d","messagePattern":"unexpected status code: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/desktop/client.go","lineNumber":127,"sourceCode":"}\n\n// Ping is a minimal API used to ensure that the server is available.\nfunc (c *Client) Ping(ctx context.Context) (*PingResponse, error) {\n\treq, err := c.newRequest(ctx, http.MethodGet, \"/ping\", http.NoBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"unexpected status code: %d\", resp.StatusCode)\n\t}\n\n\tvar ret PingResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &ret, nil\n}\n\ntype FeatureFlagResponse map[string]FeatureFlagValue\n\ntype FeatureFlagValue struct {\n\tEnabled bool `json:\"enabled\"`\n}\n\nfunc (c *Client) FeatureFlags(ctx context.Context) (FeatureFlagResponse, error) {\n\treq, err := c.newRequest(ctx, http.MethodGet, \"/features\", http.NoBody)\n\tif err != nil {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/internal/desktop/client.go#L109-L145","documentation":"internal/desktop.Client's Ping (GET on the DD backend API, typically /ping) returned any HTTP status other than 200, so the response body is not decoded and this generic status error is returned. The client talks to Docker Desktop's internal backend over its socket; a non-200 usually means version skew (endpoint missing/renamed), auth rejection, or the backend being in a bad state. Callers use Ping to decide whether Docker Desktop integration (and its feature flags) is available.","triggerScenarios":"Calling desktop.Client.Ping when the DD backend answered with e.g. 404 (old DD without the endpoint), 401/403 (auth-protected backend), 500 (backend crash), or a redirect followed by an error page from a proxy in front of the socket.","commonSituations":"Old Docker Desktop version predating the backend API used by a newer compose binary; mixed installs where DOCKER_HOST points at DD's socket but the desktop app is half-upgraded; CI environments with a Docker Desktop-like socket proxy; DD backend restarting exactly when compose pings it.","solutions":["Update Docker Desktop to a version matching your compose release (bundle skew is the most common cause).","Restart Docker Desktop so its backend API is fully up, then retry the compose command.","Inspect what the backend actually returns: curl --unix-socket <dd-socket> http://localhost/ping and check the status/body.","If you do not need DD integration, set DOCKER_HOST to the plain engine socket so the desktop client is not used.","Code that treats Ping failure as 'DD not present' should degrade gracefully rather than failing the command."],"exampleFix":"// caller degrades gracefully instead of failing\nif _, err := client.Ping(ctx); err != nil {\n    // Docker Desktop integration unavailable; continue without it\n    slog.Debug(\"desktop ping failed\", \"err\", err)\n    return nil\n}","handlingStrategy":"fallback","validationCode":"// preflight with a plain HTTP call before relying on the client\nresp, err := http.Get(ddPingURL) // over the DD socket transport\nif err != nil || resp.StatusCode != http.StatusOK {\n    // skip desktop integration for this run\n}","typeGuard":null,"tryCatchPattern":"if _, err := client.Ping(ctx); err != nil {\n    // degrade: treat Docker Desktop as absent, do not fail the command\n    slog.Debug(\"docker desktop unavailable\", \"err\", err)\n    useDesktopIntegration = false\n}","preventionTips":["Treat Ping failure as 'integration unavailable', never as fatal.","Keep Docker Desktop and compose versions in lockstep.","Cache the ping result only for the command's duration; re-check next run."],"tags":["docker-desktop","http","api-client","status-code"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}