{"record":{"id":"2b48195caeff1a94","repo":"crowdsecurity/crowdsec","slug":"while-configuring-s-w","errorCode":null,"errorMessage":"while configuring %s: %w","messagePattern":"while configuring (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csplugin/broker.go","lineNumber":322,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, pc := range pb.pluginConfigByName {\n\t\t\tif pc.Type != pSubtype {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdata, err := yaml.Marshal(pc)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tdata = []byte(csstring.StrictExpand(string(data), os.LookupEnv))\n\n\t\t\t_, err = pluginClient.Configure(ctx, &protobufs.Config{Config: data})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"while configuring %s: %w\", pc.Name, err)\n\t\t\t}\n\n\t\t\tlog.Infof(\"registered plugin %s\", pc.Name)\n\n\t\t\tpb.notificationPluginByName[pc.Name] = pluginClient\n\t\t}\n\t}\n\n\treturn pb.verifyPluginBinaryWithProfile()\n}\n\nfunc (pb *PluginBroker) loadNotificationPlugin(ctx context.Context, name string, binaryPath string) (protobufs.NotifierServer, error) {\n\thandshake, err := getHandshake()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Debugf(\"Executing plugin %s\", binaryPath)","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csplugin/broker.go#L304-L340","documentation":"loadPlugins spawns each plugin binary, connects over gRPC, and sends its config via pluginClient.Configure(ctx, &protobufs.Config{Config: data}) where data is the env-expanded yaml. If the plugin rejects the config or the RPC fails, the plugin name and error are wrapped as \"while configuring %s: %w\". It means the plugin process itself (or the transport to it) refused the registration.","triggerScenarios":"PluginBroker.Init -> loadPlugins: gRPC Configure call returns error — plugin process crashed/exited, plugin validates config and rejects it (bad API key, missing fields), env expansion (StrictExpand) produced invalid yaml, or socket/timeout issues.","commonSituations":"Notification plugin config contains an unset env var reference ($SLACK_WEBHOOK_URL unset) leading to invalid value; plugin rejects config because of missing required field; plugin binary incompatible with the protobufs API version; plugin panics on startup.","solutions":["Run the plugin binary manually with the config to see its own validation error.","Verify all env vars referenced in the notification yaml are set in crowdsec's environment (StrictExpand fails on unset vars).","Check that required config fields for the plugin type (api_key, webhook url, etc.) are present and valid.","Rebuild/reinstall the plugin binary so its protobufs version matches crowdsec's."],"exampleFix":"// before: unset env var in yaml\napi_key: ${SLACK_API_KEY}\n// after: export it for the crowdsec process\nexport SLACK_API_KEY=xoxb-... && systemctl restart crowdsec","handlingStrategy":"try-catch","validationCode":"// pre-flight: expand env vars used in notification yamls\ncsstring.StrictExpand(data, os.LookupEnv) // run before Configure to catch unset vars early","typeGuard":null,"tryCatchPattern":"resp, err := pluginClient.Configure(ctx, cfgProto)\nif err != nil {\n    log.Errorf(\"plugin %s rejected config: %v; validate yaml and env vars\", pc.Name, err)\n    return err\n}","preventionTips":["Export all env vars referenced with ${VAR} in notification yamls for the crowdsec service (systemd EnvironmentFile).","Test plugins manually by running the binary and feeding the same config.","Keep plugin binaries and crowdsec versions in sync (upgrade together)."],"tags":["grpc","plugins","config","environment"],"backgroundTag":"api-request-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"}