diff --git a/app/docker/views/services/edit/serviceController.js b/app/docker/views/services/edit/serviceController.js index dace78d40..ad826a8bc 100644 --- a/app/docker/views/services/edit/serviceController.js +++ b/app/docker/views/services/edit/serviceController.js @@ -475,7 +475,7 @@ angular.module('portainer.docker').controller('ServiceController', [ ''; if (oldCredSpecId && !credSpecId) { delete config.TaskTemplate.ContainerSpec.Privileges.CredentialSpec; - } else if (oldCredSpecId !== credSpec) { + } else if (credSpec && oldCredSpecId !== credSpec) { config.TaskTemplate.ContainerSpec.Privileges = { ...(config.TaskTemplate.ContainerSpec.Privileges || {}), CredentialSpec: { @@ -855,6 +855,10 @@ angular.module('portainer.docker').controller('ServiceController', [ $scope.filterConfigs = filterConfigs; function filterConfigs(configs) { + if (!configs) { + return []; + } + return configs.filter((config) => $scope.service.ServiceConfigs.every((serviceConfig) => config.Id !== serviceConfig.Id)); }