{"record":{"id":"5716d07d7b661e9b","repo":"crowdsecurity/crowdsec","slug":"service-name-regexp-w","errorCode":null,"errorMessage":"service_name_regexp: %w","messagePattern":"service_name_regexp: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/docker/config.go","lineNumber":113,"sourceCode":"\t\t\treturn fmt.Errorf(\"container_name_regexp: %w\", err)\n\t\t}\n\n\t\td.compiledContainerName = append(d.compiledContainerName, compiled)\n\t}\n\n\tfor _, cont := range d.Config.ContainerIDRegexp {\n\t\tcompiled, err := regexp.Compile(cont)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"container_id_regexp: %w\", err)\n\t\t}\n\n\t\td.compiledContainerID = append(d.compiledContainerID, compiled)\n\t}\n\n\tfor _, svc := range d.Config.ServiceNameRegexp {\n\t\tcompiled, err := regexp.Compile(svc)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"service_name_regexp: %w\", err)\n\t\t}\n\n\t\td.compiledServiceName = append(d.compiledServiceName, compiled)\n\t}\n\n\tfor _, svc := range d.Config.ServiceIDRegexp {\n\t\tcompiled, err := regexp.Compile(svc)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"service_id_regexp: %w\", err)\n\t\t}\n\n\t\td.compiledServiceID = append(d.compiledServiceID, compiled)\n\t}\n\n\tif d.Config.Since == \"\" {\n\t\td.Config.Since = time.Now().UTC().Format(time.RFC3339)\n\t}\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/docker/config.go#L95-L131","documentation":"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.","triggerScenarios":"UnmarshalConfig iterating d.Config.ServiceNameRegexp and encountering a string regexp.Compile rejects (unbalanced parentheses, dangling `+`/`*`, invalid character class, RE2-unsupported syntax).","commonSituations":"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.","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."],"exampleFix":"// before\nservice_name_regexp:\n  - \"my-svc(?<env>prod)\"  // Go has no named backref syntax like PCRE here\n// after\nservice_name_regexp:\n  - \"my-svc-(prod|staging)\"","handlingStrategy":"validation","validationCode":"for _, re := range cfg.ServiceNameRegexp {\n    if _, err := regexp.Compile(re); err != nil {\n        return fmt.Errorf(\"invalid service_name_regexp %q: %w\", re, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["regex","config","docker"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}