crowdsecurity/crowdsec · error

crowdsec configuration not loaded while initializing appsec

Error message

crowdsec configuration not loaded while initializing appsec - this is a bug, plese report

What it means

Raised in DataSourceConfigure when an appsec datasource implements LAPIClientAware but the global crowdsec configuration (csconfig.GetConfig().API) is nil, so no LAPI client can be built for it. This is a bug sentinel: it means the acquisition subsystem was started without the API configuration having been loaded first — an internal initialization-order defect, not a user config error.

Source

Thrown at pkg/acquisition/acquisition.go:94

	}

	clog := logging.SubLogger(log.StandardLogger(), "acquisition."+commonConfig.Source, commonConfig.LogLevel)
	subLogger := clog.WithField("type", commonConfig.Source)

	if commonConfig.Name != "" {
		subLogger = subLogger.WithField("name", commonConfig.Name)
	}

	subLogger.Info("Configuring datasource")

	if hubAware, ok := dataSrc.(types.HubAware); ok {
		hubAware.SetHub(hub)
	}

	if lapiClientAware, ok := dataSrc.(types.LAPIClientAware); ok {
		cConfig := csconfig.GetConfig()
		if cConfig.API == nil {
			return nil, errors.New("crowdsec configuration not loaded while initializing appsec - this is a bug, plese report")
		}
		lapiClientAware.SetClientConfig(cConfig.API.Client)
	}

	/* configure the actual datasource */
	if err := dataSrc.Configure(ctx, yamlConfig, subLogger, metricsLevel); err != nil {
		return nil, err
	}

	return dataSrc, nil
}

func LoadAcquisitionFromDSN(
	ctx context.Context,
	dsn string,
	labels map[string]string,
	transformExpr string,
	hub *cwhub.Hub,

View on GitHub (pinned to 909b515798)

Solutions

  1. Do not attempt to configure acquisition before the API config is loaded; ensure the crowdsec config load runs before DataSourceConfigure
  2. If you see this as a user, report it — the message itself says 'this is a bug, please report'
  3. Check that the appsec datasource is not being instantiated by a code path (e.g. cscli or tests) that never loads csconfig.API
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/acquisition/acquisition.go:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/6d6e147d411d9ecf. Report an issue: GitHub.