{"record":{"id":"ba096164af7ecb75","repo":"crowdsecurity/crowdsec","slug":"container-name-regexp-w","errorCode":null,"errorMessage":"container_name_regexp: %w","messagePattern":"container_name_regexp: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/docker/config.go","lineNumber":95,"sourceCode":"\t\treturn errors.New(\"use_service_labels and service_name, service_id, service_id_regexp, service_name_regexp are mutually exclusive\")\n\t}\n\n\tif d.Config.CheckInterval != \"\" && d.logger != nil {\n\t\td.logger.Warn(\"check_interval is ignored: this datasource now uses events instead of polling (will be removed in a future version)\")\n\t}\n\n\tif d.Config.Mode == \"\" {\n\t\td.Config.Mode = configuration.TAIL_MODE\n\t}\n\n\tif d.Config.Mode != configuration.CAT_MODE && d.Config.Mode != configuration.TAIL_MODE {\n\t\treturn fmt.Errorf(\"unsupported mode %s for docker datasource\", d.Config.Mode)\n\t}\n\n\tfor _, cont := range d.Config.ContainerNameRegexp {\n\t\tcompiled, err := regexp.Compile(cont)\n\t\tif err != nil {\n\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)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/docker/config.go#L77-L113","documentation":"Each container_name_regexp entry is compiled with regexp.Compile during UnmarshalConfig. An invalid Go regular expression fails compilation and is wrapped as `container_name_regexp: <err>`, rejecting the docker datasource configuration.","triggerScenarios":"Acquisition YAML contains a malformed regex in container_name_regexp, e.g. unbalanced parenthesis `foo(bar`, dangling escape `foo\\` or invalid repetition `foo{2,1}`.","commonSituations":"Users writing PCRE-only syntax not supported by Go's RE2 (e.g. lookahead (?=...)), copy-pasted regexes with unescaped characters, YAML mangling backslashes when not quoted.","solutions":["Fix the regex per the error's position hint — usually an unbalanced paren or dangling escape","Avoid RE2-unsupported constructs like lookaheads/lookbehinds; rewrite with plain matching","Quote the regex in YAML and double backslashes where needed to survive YAML parsing","Test the pattern with go playground regexp or `go test` before deploying"],"exampleFix":"// before\ncontainer_name_regexp:\n  - foo(?=bar)\n// after\ncontainer_name_regexp:\n  - foobar.*","handlingStrategy":"validation","validationCode":"for _, re := range cfg.ContainerNameRegexp {\n    if _, err := regexp.Compile(re); err != nil {\n        return fmt.Errorf(\"container_name_regexp %q invalid: %v\", re, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := ds.UnmarshalConfig(cfgYaml); err != nil {\n    if strings.Contains(err.Error(), \"container_name_regexp\") { /* fix the regex quoted in the wrapped error */ }\n    return err\n}","preventionTips":["Test regexes against Go's RE2 before putting them in config","Avoid lookaheads/lookbehinds — RE2 does not support them","Quote regexps in YAML to protect backslashes","Keep patterns simple; prefer literal prefixes over complex alternations"],"tags":["config","docker","regex","validation"],"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"}