{"record":{"id":"0903bdd3fe17703d","repo":"GoogleContainerTools/skaffold","slug":"compiling-name-match-regex","errorCode":null,"errorMessage":"compiling name match regex","messagePattern":"compiling name match regex","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/docker/deploy.go","lineNumber":451,"sourceCode":"\n\treturn csToDelete, nil\n}\n\nfunc (d *Deployer) getContainersCreated(ctx context.Context, img string) ([]container.Summary, error) {\n\tcl, err := d.client.ContainerList(ctx, client.ContainerListOptions{\n\t\tAll:     true,\n\t\tFilters: client.Filters{}.Add(\"label\", label.RunIDLabel).Add(\"name\", img),\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn d.filterByName(cl, img)\n}\n\nfunc (d *Deployer) filterByName(cl []container.Summary, cName string) ([]container.Summary, error) {\n\tnameMatchR, err := regexp.Compile(fmt.Sprintf(\"^/?%v(-\\\\d+)?$\", cName))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"compiling name match regex\")\n\t}\n\n\tcontainers := []container.Summary{}\n\tfor _, c := range cl {\n\t\tfor _, n := range c.Names {\n\t\t\tif nameMatchR.MatchString(n) {\n\t\t\t\tcontainers = append(containers, c)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn containers, nil\n}\n\nfunc (d *Deployer) networksToDelete(ctx context.Context, containers []container.Summary) ([]network.Summary, error) {\n\tns, err := d.client.NetworkList(ctx, client.NetworkListOptions{\n\t\tFilters: client.Filters{}.Add(\"label\", label.RunIDLabel),","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/docker/deploy.go#L433-L469","documentation":"getContainersCreated filters daemon container listings by name using a regex built from the container name: ^/?<name>(-\\d+)?$. Compiling that regex only fails if the configured container/manifest name contains invalid regex metacharacters, so this error indicates a bad name string reaching the deployer.","triggerScenarios":"filterByName (called from getContainersCreated during Deploy) builds fmt.Sprintf(\"^/?%v(-\\d+)?$\", cName) and regexp.Compile fails because the artifact/deployment name contains characters like `(`, `[`, `+`, or other regex metacharacters.","commonSituations":"skaffold.yaml with an unusual artifact image or deploy name containing dots/parentheses/plus signs (e.g. `my.app+prod`); templated names injecting special characters; copy-pasted fully qualified names with slashes or tags.","solutions":["Rename the artifact/deployment in skaffold.yaml to use only [a-zA-Z0-9-_] characters","If a literal name with dots is needed, dots are actually valid regex; check for `(`, `)`, `[`, `]`, `+`, `*`, `?` and escape or remove them","Inspect the wrapped compile error — it names the offending expression and position","If the name is generated, sanitize it before it reaches the deploy config","File/verify against skaffold if a legal Kubernetes name triggers this (potential bug: names should be regex-quoted)"],"exampleFix":"// before (skaffold.yaml)\nartifacts:\n  - image: my.app(v2)\n// after\nartifacts:\n  - image: my-app-v2","handlingStrategy":"validation","validationCode":"var nameRe = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9._-]*$`)\nfunc isRegexSafeName(name string) bool {\n  if !nameRe.MatchString(name) { return false }\n  _, err := regexp.Compile(\"^/?\" + strings.ReplaceAll(regexp.QuoteMeta(name), \"\\\\\", \"\") + \"(-\\\\d+)?$\")\n  return err == nil\n}","typeGuard":"func safeName(s string) bool {\n  for _, r := range s {\n    if strings.ContainsRune(\"()[]{}*+?|^$.\", r) && r != '.' { return false }\n  }\n  return len(s) > 0\n}","tryCatchPattern":"containers, err := getContainersCreated(ctx, cl, img)\nif err != nil && strings.Contains(err.Error(), \"compiling name match regex\") {\n  return fmt.Errorf(\"artifact/image name %q contains regex metacharacters; rename it: %w\", img, err)\n}","preventionTips":["Use only [a-z0-9-_] in artifact and deployment names in skaffold.yaml","Never put parentheses, brackets, or plus signs in image names used by the docker deployer","Sanitize templated/generated names before they reach deploy config","Validate names with a lint step before running skaffold in CI"],"tags":["docker","regex","configuration","naming"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}