docker/compose · warning · ErrCanceled

canceled

Error message

canceled

What it means

api.ErrCanceled marks user-initiated cancellation. It is returned when the user declines an interactive prompt (e.g. `docker compose publish` asking for confirmation and the user says no — pkg/compose/publish.go returns api.ErrCanceled), and the root command maps it to a friendlier exit path via api.IsErrCanceled / context.Canceled (cmd/compose/compose.go).

Source

Thrown at pkg/api/errors.go:43

	// This will be used by VSCode to detect when creating context if the user needs to login first
	ExitCodeLoginRequired = 5
)

var (
	// ErrNotFound is returned when an object is not found
	ErrNotFound = errors.New("not found")
	// ErrAlreadyExists is returned when an object already exists
	ErrAlreadyExists = errors.New("already exists")
	// ErrForbidden is returned when an operation is not permitted
	ErrForbidden = errors.New("forbidden")
	// ErrUnknown is returned when the error type is unmapped
	ErrUnknown = errors.New("unknown")
	// ErrNotImplemented is returned when a backend doesn't implement an action
	ErrNotImplemented = errors.New("not implemented")
	// ErrUnsupportedFlag is returned when a backend doesn't support a flag
	ErrUnsupportedFlag = errors.New("unsupported flag")
	// ErrCanceled is returned when the command was canceled by user
	ErrCanceled = errors.New("canceled")
	// ErrParsingFailed is returned when a string cannot be parsed
	ErrParsingFailed = errors.New("parsing failed")
	// ErrNoResources is returned when operation didn't selected any resource
	ErrNoResources = errors.New("no resources")
)

// IsNotFoundError returns true if the unwrapped error is ErrNotFound
func IsNotFoundError(err error) bool {
	return errors.Is(err, ErrNotFound)
}

// IsAlreadyExistsError returns true if the unwrapped error is ErrAlreadyExists
func IsAlreadyExistsError(err error) bool {
	return errors.Is(err, ErrAlreadyExists)
}

// IsForbiddenError returns true if the unwrapped error is ErrForbidden
func IsForbiddenError(err error) bool {

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. If the cancellation was unintentional, re-run and confirm the prompt (or pass the non-interactive options the command offers so no prompt appears).
  2. In scripts, pass required flags (e.g. --with-environment or the appropriate opt-in) so no interactive confirmation is needed.
  3. In Go code, treat api.IsErrCanceled(err) as a clean exit (not a failure), e.g. exit 0 or a dedicated code.

Example fix

# before: interactive prompt auto-declined in CI
docker compose publish myorg/myapp

# after: skip the prompt explicitly where supported
docker compose publish --yes myorg/myapp 2>/dev/null || docker compose publish myorg/myapp < <(echo y)
Defensive patterns

Strategy: try-catch

Validate before calling

# avoid interactive prompts in automation
export COMPOSE_ANSI=never
printf 'y\n' | docker compose publish "$REPO" # or pass the non-interactive opt-in flag

Type guard

func isCanceled(err error) bool { return api.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) }

Try / catch

if err := backend.Publish(ctx, project, repo, opts); err != nil {
    if api.IsErrCanceled(err) {
        return nil // user declined: clean exit, not a failure
    }
    return err
}

Prevention

When it happens

Trigger: Answering 'no' to the publish confirmation prompt; aborting an interactive api operation; ctrl-c flows where cancellation is surfaced as this sentinel rather than a raw context error.

Common situations: Non-interactive CI runs that unexpectedly hit a prompt and auto-decline; users aborting publish because the environment variables to be embedded looked wrong.

Related errors


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/313a6886fa9e0861. Report an issue: GitHub.