{"record":{"id":"30d20378a8aee62f","repo":"crowdsecurity/crowdsec","slug":"while-adding-event-handler-for-namespace-q-select","errorCode":null,"errorMessage":"while adding event handler for namespace=%q selector=%q: %w","messagePattern":"while adding event handler for namespace=%q selector=%q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kubernetes/run.go","lineNumber":158,"sourceCode":"\t\t},\n\t\tDeleteFunc: func(obj any) {\n\t\t\tpod, ok := obj.(*corev1.Pod)\n\t\t\tif !ok {\n\t\t\t\tt, _ := obj.(cache.DeletedFinalStateUnknown)\n\t\t\t\tpod, _ = t.Obj.(*corev1.Pod)\n\t\t\t\ts.logger.Debugf(\"DELETE(tombstone) %s\", podRef(pod))\n\t\t\t} else {\n\t\t\t\ts.logger.Debugf(\"DELETE %s\", podRef(pod))\n\t\t\t}\n\n\t\t\tif pod != nil {\n\t\t\t\ts.stopPod(pod)\n\t\t\t}\n\t\t},\n\t})\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"while adding event handler for namespace=%q selector=%q: %w\", s.config.Namespace, s.config.Selector, err)\n\t}\n\tf.Start(informerCtx.Done())\n\tif !cache.WaitForCacheSync(informerCtx.Done(), inf.HasSynced) {\n\t\tselect {\n\t\tcase watchErr := <-watchErrCh:\n\t\t\treturn watchErr\n\t\tdefault:\n\t\t}\n\t\treturn fmt.Errorf(\"cache sync failed for namespace=%q selector=%q\", s.config.Namespace, s.config.Selector)\n\t}\n\n\tselect {\n\tcase <-ctx.Done():\n\tcase watchErr := <-watchErrCh:\n\t\ts.stopPods()\n\t\twg.Wait()\n\t\treturn watchErr\n\t}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kubernetes/run.go#L140-L176","documentation":"In Stream, inf.AddEventHandler rejected the pod event handlers (typically called after the informer has already started); the source cannot track pod add/update/delete, so startup fails for this namespace/selector.","triggerScenarios":"Thrown at pkg/acquisition/modules/kubernetes/run.go:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restart crowdsec to recreate the informer","Report a bug if it occurs at normal startup"],"exampleFix":null,"handlingStrategy":"fallback","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"}