From 52eec11d162427e9d720606496692fe434a85d36 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sat, 28 Mar 2026 13:54:05 +0300 Subject: [PATCH] fix: registry test endpoint accepts empty body for connectivity check --- internal/api/registries.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/api/registries.go b/internal/api/registries.go index ea73c33..bd28db6 100644 --- a/internal/api/registries.go +++ b/internal/api/registries.go @@ -180,14 +180,12 @@ func (s *Server) testRegistry(w http.ResponseWriter, r *http.Request) { return } + // Body is optional — if no image provided, just test connectivity. var req testRegistryRequest - if !decodeJSON(w, r, &req) { - return - } - - if req.Image == "" { - respondError(w, http.StatusBadRequest, "image is required for testing") - return + if r.Body != nil && r.ContentLength > 0 { + if !decodeJSON(w, r, &req) { + return + } } // Decrypt the token. @@ -207,6 +205,14 @@ func (s *Server) testRegistry(w http.ResponseWriter, r *http.Request) { return } + // If no image provided, just verify we can create a client (basic connectivity test). + if req.Image == "" { + respondJSON(w, http.StatusOK, map[string]any{ + "message": "registry client created successfully", + }) + return + } + tags, err := client.ListTags(r.Context(), req.Image) if err != nil { respondError(w, http.StatusBadGateway, "registry test failed: "+err.Error())