{"record":{"id":"ed2b438b8f5b7548","repo":"crowdsecurity/crowdsec","slug":"loading-plugin-w","errorCode":null,"errorMessage":"loading plugin: %w","messagePattern":"loading plugin: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csplugin/broker.go","lineNumber":108,"sourceCode":"\ntype PluginConfigList []PluginConfig\n\nfunc (pb *PluginBroker) Init(ctx context.Context, pluginCfg *csconfig.PluginCfg, profileConfigs []*csconfig.ProfileCfg, configPaths *csconfig.ConfigurationPaths) error {\n\tpb.PluginChannel = make(chan models.ProfileAlert)\n\tpb.notificationPluginByName = make(map[string]protobufs.NotifierServer)\n\tpb.pluginMap = make(map[string]plugin.Plugin)\n\tpb.pluginConfigByName = make(map[string]PluginConfig)\n\tpb.alertsByPluginName = make(map[string][]*models.Alert)\n\tpb.profileConfigs = profileConfigs\n\tpb.pluginProcConfig = pluginCfg\n\tpb.pluginsTypesToDispatch = make(map[string]struct{})\n\n\tif err := pb.loadConfig(configPaths.NotificationDir); err != nil {\n\t\treturn fmt.Errorf(\"loading config: %w\", err)\n\t}\n\n\tif err := pb.loadPlugins(ctx, configPaths.PluginDir); err != nil {\n\t\treturn fmt.Errorf(\"loading plugin: %w\", err)\n\t}\n\n\tpb.watcher = PluginWatcher{}\n\tpb.watcher.Init(pb.pluginConfigByName, pb.alertsByPluginName)\n\n\treturn nil\n}\n\nfunc (pb *PluginBroker) ensureBackoff() backoffFactory {\n\tif pb.newBackoff == nil {\n\t\tpb.newBackoff = defaultBackoffFactory\n\t}\n\treturn pb.newBackoff\n}\n\nfunc (pb *PluginBroker) Kill() {\n\tfor _, kill := range pb.pluginKillMethods {\n\t\tkill()","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csplugin/broker.go#L90-L126","documentation":"Init wraps any failure from loadPlugins (discover, spawn via gRPC, and register each notification plugin binary) with the message \"loading plugin: %w\". It is the top-level wrapper: the underlying cause (bad binary, failed startup, config error) is chained. If it fires, the plugin broker could not bring up one or more notification plugins and crowdsec cannot dispatch notifications to them.","triggerScenarios":"Calling PluginBroker.Init(ctx, configPaths) when loadPlugins fails: a plugin binary is missing from the plugin directory, a binary is not executable, or the plugin fails its gRPC Configure handshake (see error 805).","commonSituations":"Notification plugin binaries (e.g. notification-email, notification-slack) not installed in /var/lib/crowdsec/plugins or the configured plugin_dir; plugin binary built for the wrong architecture; plugin crashes on startup so Configure fails.","solutions":["Check the wrapped cause (%w) in the log to see the actual failure (binary not found vs configure error).","Verify plugin binaries exist in the configured plugin_dir and are executable (chmod +x).","Confirm profile.yaml notifications reference plugins that have both a config file and a binary installed.","Rebuild/reinstall the notification plugin from the crowdsec-hub and re-run crowdsec."],"exampleFix":"// before: binary missing in default dir\n// after: point config at the right dir\ncrowdsec:\n  plugin_dir: /usr/local/lib/crowdsec/plugins/\n  notification_dir: /etc/crowdsec/notifications/","handlingStrategy":"try-catch","validationCode":"// before Init\nfor _, bin := range expectedPlugins {\n    if fi, err := os.Stat(filepath.Join(pluginDir, bin)); err != nil || fi.IsDir() {\n        return fmt.Errorf(\"plugin binary %s missing in %s\", bin, pluginDir)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := broker.Init(ctx, cfg); err != nil {\n    var loadErr error\n    if errors.Unwrap(err) != nil { loadErr = errors.Unwrap(err) }\n    log.Fatalf(\"plugin broker init failed: %v (cause: %v)\", err, loadErr)\n}","preventionTips":["Install notification plugin binaries with the package manager so paths and exec bits are right.","Smoke-test plugins with scripts/test_env.sh before production config changes.","Keep plugin_dir and notification_dir explicitly set in crowdsec.yaml."],"tags":["plugins","notifications","startup","grpc"],"backgroundTag":"module-init-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"}