Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: send notifications on a context detached from the completed activity (#2980)
Kyle Mendell07dac24d0680
diff --git a/backend/api/env_scoped_permission_test.go b/backend/api/env_scoped_permission_test.goindex 307294d1b..df8df69c0 100644--- a/backend/api/env_scoped_permission_test.go+++ b/backend/api/env_scoped_permission_test.go@@ -41,11 +41,6 @@ func TestEnvScopedOperationsDeclarePermission(t *testing.T) {if op.Security != nil && len(op.Security) == 0 {continue}- // Operations registered with RegisterWithoutPermission are- // intentionally permission-free (auth-only) and carry a marker.- if _, ok := op.Metadata[authz.MetaProxyNoPermission]; ok {- continue- }perm, ok := op.Metadata[authz.MetaRequiredPermission].(string)if !ok || perm == "" {missing = append(missing, method+" "+path)diff --git a/backend/api/middleware/role.go b/backend/api/middleware/role.goindex 41aaa551f..a0ccb3a3f 100644--- a/backend/api/middleware/role.go+++ b/backend/api/middleware/role.go@@ -35,23 +35,6 @@ func RegisterWithPermission[I, O any](api huma.API, op huma.Operation, perm strihuma.Register(api, op, handler)}-// RegisterWithoutPermission registers an environment-scoped Huma operation that-// requires authentication but no specific permission. It records a metadata-// marker (authz.MetaProxyNoPermission) so the remote environment proxy allows-// the operation for any authenticated caller instead of denying it by default,-// and so the env-scoped permission guard test recognizes the operation as-// intentionally permission-free.-//-// Use this ONLY for intentionally low-sensitivity endpoints (for example a-// health check). Operations that act on resources must use RegisterWithPermission.-func RegisterWithoutPermission[I, O any](api huma.API, op huma.Operation, handler func(context.Context, *I) (*O, error)) {- if op.Metadata == nil {- op.Metadata = map[string]any{}- }- op.Metadata[authz.MetaProxyNoPermission] = true- huma.Register(api, op, handler)-}-// RequirePermission returns a per-operation Huma middleware that rejects// callers lacking `perm`. For env-scoped permissions, the env ID is extracted// from the request path (/environments/{id}/...). For org-level permissions,diff --git a/backend/internal/services/image_update_service.go b/backend/internal/services/image_update_service.goindex 04757fc8b..351196ba6 100644--- a/backend/internal/services/image_update_service.go+++ b/backend/internal/services/image_update_service.go@@ -1287,6 +1287,12 @@ func (s *ImageUpdateService) sendBatchImageUpdateNotificationsInternal(ctx contereturn}+ // completeImageUpdateActivityInternal cancels the activity-tracked ctx before+ // we reach here, so detach from that cancellation (mirrors the helper it uses)+ // — otherwise the unnotified-updates query dies with "context canceled" and no+ // notification is ever dispatched.+ ctx = utils.ActivityRuntimeContext(ctx, nil)+notifCtx, cancel := context.WithTimeout(ctx, 30*time.Second)defer cancel()diff --git a/backend/internal/services/image_update_service_test.go b/backend/internal/services/image_update_service_test.goindex 0ba18870d..5c4c1a36c 100644--- a/backend/internal/services/image_update_service_test.go+++ b/backend/internal/services/image_update_service_test.go@@ -1298,6 +1298,40 @@ func TestImageUpdateService_MarkUpdatesAsNotified_EmptyList(t *testing.T) {require.NoError(t, err)}+// TestImageUpdateService_SendBatchNotifications_DetachesCanceledContext guards the+// regression where completeImageUpdateActivityInternal cancels the activity-tracked+// ctx before the batch notification step runs, killing the unnotified-updates query+// with "context canceled" so notifications were never dispatched (issue #2920).+func TestImageUpdateService_SendBatchNotifications_DetachesCanceledContext(t *testing.T) {+ db := setupImageUpdateTestDB(t)+ require.NoError(t, db.AutoMigrate(&models.NotificationSettings{}))++ notif := NewNotificationService(db, nil, nil)+ svc := NewImageUpdateService(db, nil, nil, nil, nil, notif, nil)++ rec := models.ImageUpdateRecord{+ ID: "sha256:img1",+ Repository: "test/repo",+ Tag: "latest",+ HasUpdate: true,+ NotificationSent: false,+ }+ require.NoError(t, db.Create(&rec).Error)++ // Simulate the post-activity-completion state: the tracked ctx is already canceled.+ ctx, cancel := context.WithCancel(context.Background())+ cancel()++ svc.sendBatchImageUpdateNotificationsInternal(ctx)++ // With no providers configured the send is a no-op success, so the record being+ // marked notified proves GetUnnotifiedUpdates + MarkUpdatesAsNotified ran despite+ // the canceled parent ctx.+ var reloaded models.ImageUpdateRecord+ require.NoError(t, db.First(&reloaded, "id = ?", "sha256:img1").Error)+ assert.True(t, reloaded.NotificationSent)+}+func TestImageUpdateService_GetUpdateSummaryForImageIDs_FiltersToLiveImages(t *testing.T) {ctx := context.Background()db := setupImageUpdateTestDB(t)diff --git a/backend/pkg/authz/permission_matcher_huma.go b/backend/pkg/authz/permission_matcher_huma.goindex 7398c536b..c1e38efa0 100644--- a/backend/pkg/authz/permission_matcher_huma.go+++ b/backend/pkg/authz/permission_matcher_huma.go@@ -14,12 +14,6 @@ import (// to an agent.const MetaRequiredPermission = "arcane:requiredPermission"-// MetaProxyNoPermission is the huma.Operation.Metadata key that marks an-// environment-scoped operation as intentionally requiring no specific-// permission (only authentication). The remote environment proxy allows such-// operations for any authenticated caller instead of denying them by default.-const MetaProxyNoPermission = "arcane:proxyNoPermission"-const envPathPrefixInternal = "/environments/{id}"// CollectFromHumaAPI walks every operation registered on humaAPI and records,@@ -52,12 +46,10 @@ func (m *PermissionMatcher) CollectFromHumaAPI(humaAPI huma.API) {continue}// An environment-scoped operation that declares no required- // permission is only allowed through the proxy when it is- // intentionally permission-free: either an explicitly public- // endpoint (empty Security) or one registered with- // RegisterWithoutPermission. Anything else is left unmapped and- // denied by default.- if isPublicOperationInternal(op) || isProxyNoPermissionInternal(op) {+ // permission is only allowed through the proxy when it is an+ // explicitly public endpoint (empty Security). Anything else is+ // left unmapped and denied by default.+ if isPublicOperationInternal(op) {m.AddPublic(method, suffix)}}@@ -95,17 +87,6 @@ func isPublicOperationInternal(op *huma.Operation) bool {return op.Security != nil && len(op.Security) == 0}-// isProxyNoPermissionInternal reports whether op is marked as intentionally-// requiring no specific permission (only authentication) via the-// MetaProxyNoPermission metadata key set by RegisterWithoutPermission.-func isProxyNoPermissionInternal(op *huma.Operation) bool {- if op.Metadata == nil {- return false- }- v, ok := op.Metadata[MetaProxyNoPermission].(bool)- return ok && v-}-func operationsByMethodInternal(item *huma.PathItem) map[string]*huma.Operation {return map[string]*huma.Operation{http.MethodGet: item.Get,