portainer/portainer · error

Unable to retrieve stacks: %w

Error message

Unable to retrieve stacks: %w

What it means

Error "Unable to retrieve stacks: %w" thrown in portainer/portainer.

Source

Thrown at api/http/handler/docker/utils/get_stacks.go:29

	"github.com/portainer/portainer/api/http/security"
	"github.com/portainer/portainer/api/uac"
)

type StackViewModel struct {
	InternalStack *portainer.Stack

	ID         portainer.StackID
	Name       string
	IsExternal bool
	Type       portainer.StackType
	Labels     map[string]string
}

// GetDockerStacks retrieves all the stacks associated to a specific environment filtered by the user's access.
func GetDockerStacks(tx dataservices.DataStoreTx, securityContext *security.RestrictedRequestContext, environmentID portainer.EndpointID, containers []types.Container, services []swarm.Service) ([]StackViewModel, error) {
	stacks, err := tx.Stack().ReadAll()
	if err != nil {
		return nil, fmt.Errorf("Unable to retrieve stacks: %w", err)
	}

	user, err := tx.User().Read(securityContext.UserID)
	if err != nil {
		return nil, fmt.Errorf("Unable to retrieve user: %w", err)
	}

	stacksNameSet := map[string]*StackViewModel{}

	for i := range stacks {
		stack := stacks[i]
		if stack.EndpointID == environmentID {
			stacksNameSet[stack.Name] = &StackViewModel{
				InternalStack: &stack,
				ID:            stack.ID,
				Name:          stack.Name,
				IsExternal:    false,
				Type:          stack.Type,

View on GitHub (pinned to 17e74456ff)

When it happens

Trigger: Thrown at api/http/handler/docker/utils/get_stacks.go:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of portainer/portainer@17e74456ff (2026-08-26). Data as JSON: /api/errors/9c33c808ddb531b8. Report an issue: GitHub.