crowdsecurity/crowdsec · error
service_name_regexp: %w
Error message
service_name_regexp: %w
What it means
Same mechanism as container_id_regexp but for the `service_name_regexp` list: each entry is compiled with regexp.Compile during UnmarshalConfig, and an invalid pattern aborts configuration with this wrapped error. It indicates a syntactically invalid RE2 regular expression in the service_name_regexp config.
Source
Thrown at pkg/acquisition/modules/docker/config.go:113
return fmt.Errorf("container_name_regexp: %w", err)
}
d.compiledContainerName = append(d.compiledContainerName, compiled)
}
for _, cont := range d.Config.ContainerIDRegexp {
compiled, err := regexp.Compile(cont)
if err != nil {
return fmt.Errorf("container_id_regexp: %w", err)
}
d.compiledContainerID = append(d.compiledContainerID, compiled)
}
for _, svc := range d.Config.ServiceNameRegexp {
compiled, err := regexp.Compile(svc)
if err != nil {
return fmt.Errorf("service_name_regexp: %w", err)
}
d.compiledServiceName = append(d.compiledServiceName, compiled)
}
for _, svc := range d.Config.ServiceIDRegexp {
compiled, err := regexp.Compile(svc)
if err != nil {
return fmt.Errorf("service_id_regexp: %w", err)
}
d.compiledServiceID = append(d.compiledServiceID, compiled)
}
if d.Config.Since == "" {
d.Config.Since = time.Now().UTC().Format(time.RFC3339)
}
View on GitHub (pinned to 909b515798)
Solutions
- Fix the pattern so it compiles as a Go/RE2 regex.
- Replace PCRE-only features (lookarounds, named backrefs) with RE2-compatible constructs.
- Test the pattern standalone with regexp.Compile before deploying.
- If no regex is needed, use the plain `service_name` list instead.
Example fix
// before service_name_regexp: - "my-svc(?<env>prod)" // Go has no named backref syntax like PCRE here // after service_name_regexp: - "my-svc-(prod|staging)"
Defensive patterns
Strategy: validation
Validate before calling
for _, re := range cfg.ServiceNameRegexp {
if _, err := regexp.Compile(re); err != nil {
return fmt.Errorf("invalid service_name_regexp %q: %w", re, err)
}
} Prevention
- Validate patterns against Go's RE2 engine, not your shell's grep flavor.
- Keep service regexes simple (prefix/suffix matching) to reduce syntax risk.
- Check YAML quoting — patterns with special chars should be single-quoted.
When it happens
Trigger: UnmarshalConfig iterating d.Config.ServiceNameRegexp and encountering a string regexp.Compile rejects (unbalanced parentheses, dangling `+`/`*`, invalid character class, RE2-unsupported syntax).
Common situations: Docker Swarm service filtering configured with a typo'd or PCRE-flavored regex; copy-pasted regex from a tutorial with language-specific syntax; accidentally quoting issues in YAML producing a mangled pattern.
Related errors
- container_name_regexp: %w
- container_id_regexp: %w
- service_id_regexp: %w
- while parsing DockerAcquisition configuration: %s
- unsupported mode %s for docker datasource
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/5716d07d7b661e9b.
Report an issue: GitHub.