crowdsecurity/crowdsec · info

ErrUserCanceled

ErrUserCanceled

Error message

operation canceled

What it means

ErrUserCanceled in pkg/hubops/plan.go is the sentinel returned when the user declines a hub operation plan (upgrade/install/remove/wizard) during interactive confirmation via plan.Execute. It is not a failure — CLI callers check errors.Is and exit without printing an error.

Source

Thrown at pkg/hubops/plan.go:19

package hubops

import (
	"context"
	"errors"
	"fmt"
	"io"
	"os"
	"slices"
	"strings"

	"github.com/AlecAivazis/survey/v2"

	"github.com/crowdsecurity/go-cs-lib/slicetools"

	"github.com/crowdsecurity/crowdsec/pkg/cwhub"
)

var ErrUserCanceled = errors.New("operation canceled")

// Command represents an operation that can be performed on a CrowdSec hub item.
//
// Each concrete implementation defines a Prepare() method to check for errors and preconditions,
// decide which sub-commands are required (like installing dependencies) and add them to the action plan.
type Command interface {
	// Prepare sets up the command for execution within the given
	// ActionPlan. It may add additional commands to the ActionPlan based
	// on dependencies or prerequisites. Returns a boolean indicating
	// whether the command execution should be skipped (it can be
	// redundant, like installing something that is already installed) and
	// an error if the preparation failed.
	// NOTE: Returning an error will bubble up from the plan.AddCommand() method,
	// but Prepare() might already have modified the plan's command slice.
	Prepare(plan *ActionPlan) (bool, error)

	// Run executes the command within the provided context and ActionPlan.
	// It performs the actual operation and returns an error if execution fails.

View on GitHub (pinned to 909b515798)

Solutions

  1. Nothing to fix: re-run the command and answer 'y' at the confirmation prompt
  2. Use --force or pass interactive=false / dryRun to skip the prompt in scripts
  3. Pipe 'yes |' or set non-interactive mode if automation must proceed

Example fix

err := plan.Execute(ctx, interactive, dry, showPlan, verbose)
if err != nil && !errors.Is(err, hubops.ErrUserCanceled) {
    return err
}
Defensive patterns

Strategy: try-catch

Try / catch

err := plan.Execute(ctx, interactive, dryRun, showPlan, verbosePlan)
if err != nil && !errors.Is(err, hubops.ErrUserCanceled) { return err }

Prevention

When it happens

Trigger: plan.Execute(ctx, interactive=true, ...) presented an install/upgrade/remove plan and the user answered 'no' at the confirmation prompt; also returned from wizard flows when the user aborts.

Common situations: Running 'cscli hub update/upgrade -i' or 'cscli items install' interactively and typing no/n at the prompt; scripted runs where stdin is closed may also trigger an abort.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/4837cf79e574fb1b. Report an issue: GitHub.