{"record":{"id":"d43bbb995b90defc","repo":"crowdsecurity/crowdsec","slug":"appsec-datasource-requires-a-lapi-client-configura","errorCode":null,"errorMessage":"appsec datasource requires a lapi client configuration. this is a bug, please report","messagePattern":"appsec datasource requires a lapi client configuration\\. this is a bug, please report","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/appsec/config.go","lineNumber":193,"sourceCode":"\t\t\tif _, ok := seen[name]; ok {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tseen[name] = struct{}{}\n\t\t\ttoLoad = append(toLoad, name)\n\t\t}\n\t}\n\n\treturn toLoad, nil\n}\n\nfunc (w *Source) Configure(ctx context.Context, yamlConfig []byte, logger *log.Entry, _ metrics.AcquisitionMetricsLevel) error {\n\tif w.hub == nil {\n\t\treturn errors.New(\"appsec datasource requires a hub. this is a bug, please report\")\n\t}\n\n\tif w.lapiClientConfig == nil {\n\t\treturn errors.New(\"appsec datasource requires a lapi client configuration. this is a bug, please report\")\n\t}\n\n\tif err := w.UnmarshalConfig(yamlConfig); err != nil {\n\t\treturn fmt.Errorf(\"unable to parse appsec configuration: %w\", err)\n\t}\n\n\tif w.lapiClientConfig.Credentials == nil {\n\t\treturn errors.New(\"missing lapi client credentials\")\n\t}\n\n\tw.lapiURL = fmt.Sprintf(\"%sv1/decisions/stream\", w.lapiClientConfig.Credentials.URL)\n\tw.AuthCache = NewAuthCache()\n\n\tw.logger = logger\n\tw.logger.Tracef(\"Appsec configuration: %+v\", w.config)\n\n\tif w.config.AuthCacheDuration == nil {\n\t\tw.config.AuthCacheDuration = &DefaultAuthCacheDuration","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/appsec/config.go#L175-L211","documentation":"Configure() also requires a pre-populated lapiClientConfig (the LAPI client credentials/config injected during datasource common setup). A nil value means the appsec Source was constructed without its required state. Like the hub check, this is flagged as an internal bug rather than a user-facing config error.","triggerScenarios":"appsec Source.Configure() invoked with w.lapiClientConfig == nil, i.e. the constructor/common-state initialization that wires LAPI client configuration was skipped or failed silently.","commonSituations":"Embedding the appsec datasource in a custom binary, running a stale or custom-built appsec plugin binary that no longer matches the main crowdsec initialization sequence, or plugin startup ordering issues.","solutions":["Report the bug to CrowdSec with logs","If embedding, initialize the Source's common state (lapiClientConfig) before calling Configure()","Rebuild/reinstall the appsec plugin binaries together with crowdsec (make build) to keep versions in sync"],"exampleFix":"// before\nsrc := &appsec.Source{}\nerr := src.Configure(ctx, yaml, logger, metrics)\n// after\nsrc := &appsec.Source{}\nsrc.ConfigureCommonState(state) // populates lapiClientConfig\nerr := src.Configure(ctx, yaml, logger, metrics)","handlingStrategy":"type-guard","validationCode":"if src.lapiClientConfig == nil { return errors.New(\"lapi client config not initialized\") }","typeGuard":"func lapiConfigReady(s *appsec.Source) bool { return s != nil && s.LapiClientConfig != nil }","tryCatchPattern":"if err := src.Configure(ctx, cfg, logger, lvl); err != nil {\n    if strings.Contains(err.Error(), \"lapi client configuration\") { /* re-init common state */ }\n    return err\n}","preventionTips":["Initialize datasource common state before Configure","Build crowdsec + appsec plugin from matching versions","Report occurrences as a bug with startup logs"],"tags":["appsec","acquisition","lapi","initialization"],"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-14T05:17:10.506Z"}