crowdsecurity/crowdsec · error

invalid DSN %s for file source, must start with file://

Error message

invalid DSN %s for file source, must start with file://

What it means

Returned by the file source's ConfigureByDSN when the DSN passed to crowdsec doesn't start with the required file:// scheme — the file acquisition module cannot interpret the DSN (e.g. it was routed to the wrong module or the scheme is misspelled).

Source

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

					}

					s.watchedDirectories[directory] = true
				} else {
					s.logger.Debugf("Watch for directory %s already exists", directory)
				}
			}

			s.logger.Infof("Adding file %s to datasources", file)
			s.files = append(s.files, file)
		}
	}

	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)
		}

View on GitHub (pinned to 909b515798)

Solutions

  1. Use a DSN of the form file:///var/log/foo.log
  2. Add the file:// prefix to the source's filename in the acquisition config
Defensive patterns

Strategy: validation

When it happens

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