{"record":{"id":"50cf226bca0a43a3","repo":"crowdsecurity/crowdsec","slug":"failed-to-process-line","errorCode":null,"errorMessage":"failed to process line","messagePattern":"failed to process line","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kubernetes/run.go","lineNumber":27,"sourceCode":"\t\"time\"\n\n\t\"github.com/prometheus/client_golang/prometheus\"\n\tlog \"github.com/sirupsen/logrus\"\n\tcorev1 \"k8s.io/api/core/v1\"\n\tapierrors \"k8s.io/apimachinery/pkg/api/errors\"\n\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n\t\"k8s.io/apimachinery/pkg/types\"\n\t\"k8s.io/client-go/informers\"\n\t\"k8s.io/client-go/kubernetes\"\n\t\"k8s.io/client-go/tools/cache\"\n\n\t\"github.com/crowdsecurity/crowdsec/pkg/metrics\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/pipeline\"\n)\n\n// errProcessLine marks onLineFunc failures as fatal, as opposed to stream/scan\n// errors which followPodLogs retries.\nvar errProcessLine = errors.New(\"failed to process line\")\n\nfunc podRef(p *corev1.Pod) string {\n\tif p == nil {\n\t\treturn \"<nil pod>\"\n\t}\n\treturn fmt.Sprintf(\"%s/%s uid=%s phase=%s rv=%s node=%s\",\n\t\tp.Namespace,\n\t\tp.Name,\n\t\tp.UID,\n\t\tp.Status.Phase,\n\t\tp.ResourceVersion,\n\t\tp.Spec.NodeName,\n\t)\n}\n\nfunc (s *Source) initClient() error {\n\tcfg, err := s.config.buildClientConfig(s.logger)\n\tif err != nil {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kubernetes/run.go#L9-L45","documentation":"errProcessLine is a sentinel error (pkg/acquisition/modules/kubernetes/run.go:27) that wraps failures of the per-line callback while tailing pod logs. It marks the failure as fatal: followPodLogs (run.go:231) checks errors.Is(err, errProcessLine) and returns immediately instead of retrying, because a processing failure will recur for the same line whereas stream/scan errors are transient.","triggerScenarios":"The onLineFunc passed to followPodLogs returns a non-nil error when processing a scanned line (run.go:220); followPodLogs wraps it with %w: %w into errProcessLine, which then propagates out of the retry loop unchanged.","commonSituations":"The downstream event pipeline (parsing/arsing the log line) rejects a malformed or unexpected log line emitted by a container, causing the whole log-tail for that pod to abort rather than loop forever on the same bad line.","solutions":["Inspect the wrapped inner error to find why the line failed processing (parse failure, channel closed, etc.).","Fix the parser/config so the offending log line is handled, or ensure the source's log format matches acquisition expectations.","If the failure is expected to be skippable, make onLineFunc log and return nil instead of an error so tailing continues."],"exampleFix":"// before\nif err := processLine(line); err != nil {\n    return err // aborts the whole pod tail\n}\n\n// after\nif err := processLine(line); err != nil {\n    logger.Warnf(\"skipping unparsable line: %s\", err)\n    return nil // continue tailing\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    if errors.Is(err, errProcessLine) {\n        // fatal: inspect inner cause, fix parser/config; do not retry\n        log.Fatalf(\"fatal line processing failure: %v\", err)\n    }\n    // transient stream error: safe to retry\n}","preventionTips":["Ensure the acquisition parser handles all log formats the selected pods can emit.","Prefer logging-and-skipping bad lines over returning errors from the line callback.","Check the inner wrapped error with errors.Unwrap / %w inspection to find the real cause."],"tags":["kubernetes","log-tailing","sentinel-error","error-wrapping"],"backgroundTag":"internal-invariant-violation","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"}