From cf5990ccbab23bb2baafe49c8ed437e3ea29238e Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Mon, 30 Jun 2025 20:54:16 -0300 Subject: [PATCH] fix(edgestackstatus): improve error handling BE-11963 (#844) --- api/http/handler/edgestacks/edgestack_status_update.go | 4 +++- api/http/handler/endpoints/filter.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/http/handler/edgestacks/edgestack_status_update.go b/api/http/handler/edgestacks/edgestack_status_update.go index 4f99e7ab3..0ff6a9eff 100644 --- a/api/http/handler/edgestacks/edgestack_status_update.go +++ b/api/http/handler/edgestacks/edgestack_status_update.go @@ -133,7 +133,9 @@ func (handler *Handler) updateEdgeStackStatus(tx dataservices.DataStoreTx, stack } environmentStatus, err := tx.EdgeStackStatus().Read(stackID, payload.EndpointID) - if err != nil { + if err != nil && !tx.IsErrObjectNotFound(err) { + return err + } else if tx.IsErrObjectNotFound(err) { environmentStatus = &portainer.EdgeStackStatusForEnv{ EndpointID: payload.EndpointID, Status: []portainer.EdgeStackDeploymentStatus{}, diff --git a/api/http/handler/endpoints/filter.go b/api/http/handler/endpoints/filter.go index c8b4ede08..7cf7b9760 100644 --- a/api/http/handler/endpoints/filter.go +++ b/api/http/handler/endpoints/filter.go @@ -297,7 +297,9 @@ func filterEndpointsByEdgeStack(endpoints []portainer.Endpoint, edgeStackId port n := 0 for _, envId := range envIds { edgeStackStatus, err := datastore.EdgeStackStatus().Read(edgeStackId, envId) - if err != nil { + if dataservices.IsErrObjectNotFound(err) { + continue + } else if err != nil { return nil, errors.WithMessagef(err, "Unable to retrieve edge stack status for environment %d", envId) }