{"record":{"id":"ed00e4131b21317a","repo":"crowdsecurity/crowdsec","slug":"s-is-tainted-use-force-to-remove","errorCode":null,"errorMessage":"%s is tainted, use '--force' to remove","messagePattern":"(.+?) is tainted, use '--force' to remove","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubops/disable.go","lineNumber":63,"sourceCode":"type DisableCommand struct {\n\tItem  *cwhub.Item\n\tForce bool\n}\n\nfunc NewDisableCommand(item *cwhub.Item, force bool) *DisableCommand {\n\treturn &DisableCommand{Item: item, Force: force}\n}\n\nfunc (c *DisableCommand) Prepare(plan *ActionPlan) (bool, error) {\n\ti := c.Item\n\n\tif i.State.IsLocal() {\n\t\tlog.Warnf(\"%s is a local item, please delete manually\", i.FQName())\n\t\treturn false, nil\n\t}\n\n\tif i.State.Tainted && !c.Force {\n\t\treturn false, fmt.Errorf(\"%s is tainted, use '--force' to remove\", i.Name)\n\t}\n\n\tif !i.State.IsInstalled() {\n\t\treturn false, nil\n\t}\n\n\tsubsToRemove, err := i.SafeToRemoveDeps()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tfor _, sub := range subsToRemove {\n\t\tif !sub.State.IsInstalled() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := plan.AddCommand(NewDisableCommand(sub, c.Force)); err != nil {\n\t\t\treturn false, err","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubops/disable.go#L45-L81","documentation":"The disable command's Prepare refuses to disable a hub item that is 'tainted' (locally modified) unless --force is given. The error '%s is tainted, use --force to remove' protects local customizations from being silently discarded.","triggerScenarios":"Running 'cscli <type> disable <item>' where item.State.Tainted is true and the DisableCommand's Force flag is false.","commonSituations":"User edited an installed parser/scenario in place (making it tainted) and later tries to disable or upgrade it.","solutions":["Add --force to the disable command to discard local modifications","Back up the modified file first, then disable with --force and reapply changes to a local (untainted) copy","Use 'cscli hub list' to see which items are tainted before acting"],"exampleFix":"// before\ncscli scenarios disable crowdsecurity/http-bf-generic  # tainted error\n// after\ncp /etc/crowdsec/scenarios/http-bf-generic.yaml ~/http-bf-generic.bak.yaml\ncscli scenarios disable crowdsecurity/http-bf-generic --force","handlingStrategy":"validation","validationCode":"if item.State.Tainted && !force {\n    return fmt.Errorf(\"%s is tainted; use --force or back up changes\", item.FQName())\n}","typeGuard":null,"tryCatchPattern":"if err := disableCmd.Run(ctx, plan); err != nil {\n    if strings.Contains(err.Error(), \"is tainted\") { /* prompt user to confirm --force */ }\n    return err\n}","preventionTips":["Check tainted status with 'cscli hub list' before disabling/upgrading","Keep customizations in local (untainted) files, not in installed hub items","Back up modified items before any hub operation"],"tags":["cli","hub","tainted-item"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}