{"record":{"id":"4837cf79e574fb1b","repo":"crowdsecurity/crowdsec","slug":"errusercanceled","errorCode":"ErrUserCanceled","errorMessage":"operation canceled","messagePattern":"operation canceled","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/hubops/plan.go","lineNumber":19,"sourceCode":"package hubops\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"slices\"\n\t\"strings\"\n\n\t\"github.com/AlecAivazis/survey/v2\"\n\n\t\"github.com/crowdsecurity/go-cs-lib/slicetools\"\n\n\t\"github.com/crowdsecurity/crowdsec/pkg/cwhub\"\n)\n\nvar ErrUserCanceled = errors.New(\"operation canceled\")\n\n// Command represents an operation that can be performed on a CrowdSec hub item.\n//\n// Each concrete implementation defines a Prepare() method to check for errors and preconditions,\n// decide which sub-commands are required (like installing dependencies) and add them to the action plan.\ntype Command interface {\n\t// Prepare sets up the command for execution within the given\n\t// ActionPlan. It may add additional commands to the ActionPlan based\n\t// on dependencies or prerequisites. Returns a boolean indicating\n\t// whether the command execution should be skipped (it can be\n\t// redundant, like installing something that is already installed) and\n\t// an error if the preparation failed.\n\t// NOTE: Returning an error will bubble up from the plan.AddCommand() method,\n\t// but Prepare() might already have modified the plan's command slice.\n\tPrepare(plan *ActionPlan) (bool, error)\n\n\t// Run executes the command within the provided context and ActionPlan.\n\t// It performs the actual operation and returns an error if execution fails.","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubops/plan.go#L1-L37","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Nothing to fix: re-run the command and answer 'y' at the confirmation prompt","Use --force or pass interactive=false / dryRun to skip the prompt in scripts","Pipe 'yes |' or set non-interactive mode if automation must proceed"],"exampleFix":"err := plan.Execute(ctx, interactive, dry, showPlan, verbose)\nif err != nil && !errors.Is(err, hubops.ErrUserCanceled) {\n    return err\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := plan.Execute(ctx, interactive, dryRun, showPlan, verbosePlan)\nif err != nil && !errors.Is(err, hubops.ErrUserCanceled) { return err }","preventionTips":["Use dryRun or --force in scripts to avoid interactive prompts","Always errors.Is-check ErrUserCanceled instead of treating it as failure","Provide non-interactive input when running under CI"],"tags":["go","cli","hub","user-abort"],"backgroundTag":"operation-canceled-by-user","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}