crowdsecurity/crowdsec · error

empty s3:// DSN

Error message

empty s3:// DSN

What it means

Returned by ConfigureByDSN when an s3:// DSN has no bucket name before the optional query string (the part after stripping the s3:// scheme and splitting on '?' is empty). The source cannot run without a bucket to poll.

Source

Thrown at pkg/acquisition/modules/s3/config.go:212

	return nil
}

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

	s.Config = Configuration{}
	s.logger = logger.WithFields(log.Fields{
		"bucket": s.Config.BucketName,
		"prefix": s.Config.Prefix,
	})

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

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

	if len(args) == 2 && args[1] != "" {
		params, err := url.ParseQuery(args[1])
		if err != nil {
			return fmt.Errorf("could not parse s3 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. Put the bucket (optionally with prefix) after the scheme: s3://my-bucket/optional/prefix
  2. Add query options after the path, e.g. s3://my-bucket?log_level=debug
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/acquisition/modules/s3/config.go:212 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/34a99e41d6003d25. Report an issue: GitHub.