docker/cli ยท error

invalid stack name: %q

Error message

invalid stack name: %q

What it means

Error "invalid stack name: %q" thrown in docker/cli.

Source

Thrown at cli/command/stack/common.go:20

import (
	"context"
	"fmt"
	"strings"
	"unicode"

	"github.com/docker/cli/cli/compose/convert"
	"github.com/docker/cli/opts"
	"github.com/moby/moby/client"
)

// validateStackName checks if the provided string is a valid stack name (namespace).
// It currently only does a rudimentary check if the string is empty, or consists
// of only whitespace and quoting characters.
func validateStackName(namespace string) error {
	v := strings.TrimFunc(namespace, quotesOrWhitespace)
	if v == "" {
		return fmt.Errorf("invalid stack name: %q", namespace)
	}
	return nil
}

func validateStackNames(namespaces []string) error {
	for _, ns := range namespaces {
		if err := validateStackName(ns); err != nil {
			return err
		}
	}
	return nil
}

func quotesOrWhitespace(r rune) bool {
	return unicode.IsSpace(r) || r == '"' || r == '\''
}

func getStackFilter(namespace string) client.Filters {

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/stack/common.go:20 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/1403cc817019b691.json. Report an issue: GitHub.