crowdsecurity/crowdsec · error

empty file:// DSN

Error message

empty file:// DSN

What it means

DSN validation in the file datasource's ConfigureByDSN: after stripping the mandatory file:// prefix and splitting on '?', the path component (args[0]) is empty — the DSN names no file to tail (e.g. 'file://' or 'file://?log_level=debug').

Source

Thrown at pkg/acquisition/modules/file/config.go:164

	}

	return nil
}

func (s *Source) ConfigureByDSN(_ context.Context, dsn string, labels map[string]string, logger *log.Entry, uuid string) error {
	if !strings.HasPrefix(dsn, "file://") {
		return fmt.Errorf("invalid DSN %s for file source, must start with file://", dsn)
	}

	s.logger = logger
	s.config = Configuration{}

	dsn = strings.TrimPrefix(dsn, "file://")

	args := strings.Split(dsn, "?")

	if args[0] == "" {
		return errors.New("empty file:// DSN")
	}

	if len(args) == 2 && args[1] != "" {
		params, err := url.ParseQuery(args[1])
		if err != nil {
			return fmt.Errorf("could not parse file args: %w", err)
		}

		for key, value := range params {
			switch key {
			case "log_level":
				if len(value) != 1 {
					return errors.New("expected zero or one value for 'log_level'")
				}

				lvl, err := log.ParseLevel(value[0])
				if err != nil {
					return fmt.Errorf("unknown level %s: %w", value[0], err)

View on GitHub (pinned to 909b515798)

Solutions

  1. Include the path after the scheme: file:///var/log/nginx/access.log
  2. Put options in the query string only after a real path: file:///path/to/log?log_level=debug
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/acquisition/modules/file/config.go:164 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/9d06dccfa3a666ab. Report an issue: GitHub.