{"record":{"id":"36e5fa2cbc83a0f6","repo":"crowdsecurity/crowdsec","slug":"expiring-decisions-error-w","errorCode":null,"errorMessage":"expiring decisions error: %w","messagePattern":"expiring decisions error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiserver/apic.go","lineNumber":466,"sourceCode":"\nfunc (a *apic) HandleDeletedDecisionsV3(ctx context.Context, deletedDecisions []*modelscapi.GetDecisionsStreamResponseDeletedItem, deleteCounters map[string]map[string]int) (int, error) {\n\tvar nbDeleted int\n\n\tfor _, decisions := range deletedDecisions {\n\t\tscope := decisions.Scope\n\n\t\tfor _, decision := range decisions.Decisions {\n\t\t\tfilter := map[string][]string{\n\t\t\t\t\"value\":  {decision},\n\t\t\t\t\"origin\": {types.CAPIOrigin},\n\t\t\t}\n\t\t\tif strings.ToLower(*scope) != \"ip\" {\n\t\t\t\tfilter[\"scopes\"] = []string{*scope}\n\t\t\t}\n\n\t\t\tdbCliDel, _, err := a.dbClient.ExpireDecisionsWithFilter(ctx, filter)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"expiring decisions error: %w\", err)\n\t\t\t}\n\n\t\t\tupdateCounterForDecision(deleteCounters, new(types.CAPIOrigin), nil, dbCliDel)\n\n\t\t\tnbDeleted += dbCliDel\n\t\t}\n\t}\n\n\treturn nbDeleted, nil\n}\n\nfunc createAlertForDecision(decision *models.Decision, kind types.AlertKind) *models.Alert {\n\tvar (\n\t\tscenario string\n\t\tscope    string\n\t)\n\n\tswitch *decision.Origin {","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiserver/apic.go#L448-L484","documentation":"While processing the CAPI decisions stream deletions (HandleDeletedDecisionsV3), expiring one deleted decision in the local database via ExpireDecisionsWithFilter failed. The CAPI stream itself was received fine; the failure is the local DB expire of a decision value in a given scope.","triggerScenarios":"Thrown at pkg/apiserver/apic.go:466 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the DB cause (deadlock, timeout, constraint)","Check DB health and capacity — the delete runs per-decision in a loop, so slow DBs can time out","If persistent, note the failing decision value/scope and check for bad data from CAPI"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}