{"record":{"id":"6481937d8c61928f","repo":"crowdsecurity/crowdsec","slug":"s-s-failed-w","errorCode":null,"errorMessage":"'%s %s failed: %w","messagePattern":"'(.+?) (.+?) failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiserver/papi.go","lineNumber":157,"sourceCode":"\t\treturn errors.New(\"no header in message, skipping\")\n\t}\n\n\tif message.Header.Source == nil {\n\t\treturn errors.New(\"no source user in header message, skipping\")\n\t}\n\n\toperationFunc, ok := operationMap[message.Header.OperationType]\n\tif !ok {\n\t\treturn fmt.Errorf(\"operation '%s' unknown, continue\", message.Header.OperationType)\n\t}\n\n\tmetrics.PapiOrdersReceived.WithLabelValues(message.Header.OperationType, message.Header.OperationCmd).Inc()\n\n\tlogger.Debugf(\"Calling operation '%s'\", message.Header.OperationType)\n\n\terr := operationFunc(ctx, message, p, sync)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"'%s %s failed: %w\", message.Header.OperationType, message.Header.OperationCmd, err)\n\t}\n\n\treturn nil\n}\n\nfunc (p *Papi) GetPermissions(ctx context.Context) (PapiPermCheckSuccess, error) {\n\thttpClient := p.apiClient.GetClient()\n\tpapiCheckURL := fmt.Sprintf(\"%s%s%s\", p.URL, PAPIVersion, PAPIPermissionsURL)\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, papiCheckURL, http.NoBody)\n\tif err != nil {\n\t\treturn PapiPermCheckSuccess{}, fmt.Errorf(\"failed to create request: %w\", err)\n\t}\n\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn PapiPermCheckSuccess{}, fmt.Errorf(\"failed to get response: %w\", err)\n\t}","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiserver/papi.go#L139-L175","documentation":"The operation handler dispatched for a PAPI message (DecisionCmd, AlertCmd or ManagementCmd via operationFunc) returned an error; handleEvent wraps it identifying which operation type and command failed. The order itself was received and matched to a handler, but executing it — applying a decision, persisting an alert, or a management action — failed against the local database or subsystems.","triggerScenarios":"operationFunc(ctx, message, p, sync) returns non-nil inside handleEvent; the wrapped error is commonly a database failure while inserting/deleting decisions or alerts, or a failure in the management command triggered by the console order.","commonSituations":"Local DB locked/corrupted or full disk while applying decisions; console management operations (e.g. disable a parser, alert commands) failing because the corresponding feature or resources are missing; permission problems on the SQLite/DB backend.","solutions":["Read the innermost wrapped error after the operation name — it pinpoints the failing step.","Check local database health: disk space, `cscli db status`-style checks, and crowdsec logs around the same time.","Retry/restart crowdsec; PAPI re-polls orders so transient DB failures usually self-heal on the next pull (sync interval 10s).","If a specific console operation always fails, check its prerequisites (e.g. console management toggles enabled with `cscli console status`) and report with the full chained error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := p.handleEvent(ctx, event, sync); err != nil {\n    logger.WithError(err).Errorf(\"PAPI operation failed\")\n    // rely on next pull cycle (SyncInterval 10s) to retry the order\n    if errors.Is(err, database.ErrDeadlockDetected) { /* backoff */ }\n}","preventionTips":["Monitor disk space and DB health on the crowdsec host; most handler failures are storage-related.","Keep SQLite file permissions owned by the crowdsec user.","Watch logs for repeated operation failures — persistent failure means an order never gets applied.","Upgrade rather than disabling console management features that your version can't execute."],"tags":["papi","database","operations"],"backgroundTag":"operation-failed","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"}