From 244b0d63feda8eb15b47f11fc128199bf63f9c78 Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Mon, 27 Jul 2026 08:59:57 -0300 Subject: [PATCH] fix(websocket): return accurate errors BE-13117 (#3276) --- api/http/handler/websocket/attach.go | 4 ++-- api/http/handler/websocket/exec.go | 4 ++-- api/http/handler/websocket/pod.go | 4 ++-- api/http/handler/websocket/shell_pod.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/http/handler/websocket/attach.go b/api/http/handler/websocket/attach.go index 999dba689a..f82c51bc94 100644 --- a/api/http/handler/websocket/attach.go +++ b/api/http/handler/websocket/attach.go @@ -50,9 +50,9 @@ func (handler *Handler) websocketAttach(w http.ResponseWriter, r *http.Request) endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID)) if handler.DataStore.IsErrObjectNotFound(err) { - return httperror.NotFound("Unable to find the environment associated to the stack inside the database", err) + return httperror.NotFound("Unable to find the environment in the database", err) } else if err != nil { - return httperror.InternalServerError("Unable to find the environment associated to the stack inside the database", err) + return httperror.InternalServerError("Unable to find the environment in the database", err) } err = handler.requestBouncer.AuthorizedEndpointOperation(r, endpoint) diff --git a/api/http/handler/websocket/exec.go b/api/http/handler/websocket/exec.go index 2ce09acb2c..88e5904029 100644 --- a/api/http/handler/websocket/exec.go +++ b/api/http/handler/websocket/exec.go @@ -53,9 +53,9 @@ func (handler *Handler) websocketExec(w http.ResponseWriter, r *http.Request) *h endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID)) if handler.DataStore.IsErrObjectNotFound(err) { - return httperror.NotFound("Unable to find the environment associated to the stack inside the database", err) + return httperror.NotFound("Unable to find the environment in the database", err) } else if err != nil { - return httperror.InternalServerError("Unable to find the environment associated to the stack inside the database", err) + return httperror.InternalServerError("Unable to find the environment in the database", err) } err = handler.requestBouncer.AuthorizedEndpointOperation(r, endpoint) diff --git a/api/http/handler/websocket/pod.go b/api/http/handler/websocket/pod.go index f57abf4109..bfd1e4bf3f 100644 --- a/api/http/handler/websocket/pod.go +++ b/api/http/handler/websocket/pod.go @@ -66,9 +66,9 @@ func (handler *Handler) websocketPodExec(w http.ResponseWriter, r *http.Request) endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID)) if handler.DataStore.IsErrObjectNotFound(err) { - return httperror.NotFound("Unable to find the environment associated to the stack inside the database", err) + return httperror.NotFound("Unable to find the environment in the database", err) } else if err != nil { - return httperror.InternalServerError("Unable to find the environment associated to the stack inside the database", err) + return httperror.InternalServerError("Unable to find the environment in the database", err) } if err := handler.requestBouncer.AuthorizedEndpointOperation(r, endpoint); err != nil { diff --git a/api/http/handler/websocket/shell_pod.go b/api/http/handler/websocket/shell_pod.go index a5e00933ce..ce5ce4ce86 100644 --- a/api/http/handler/websocket/shell_pod.go +++ b/api/http/handler/websocket/shell_pod.go @@ -32,9 +32,9 @@ func (handler *Handler) websocketShellPodExec(w http.ResponseWriter, r *http.Req endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID)) if handler.DataStore.IsErrObjectNotFound(err) { - return httperror.NotFound("Unable to find the environment associated to the stack inside the database", err) + return httperror.NotFound("Unable to find the environment in the database", err) } else if err != nil { - return httperror.InternalServerError("Unable to find the environment associated to the stack inside the database", err) + return httperror.InternalServerError("Unable to find the environment in the database", err) } if err := handler.requestBouncer.AuthorizedEndpointOperation(r, endpoint); err != nil {