{"record":{"id":"644cacf1f555d7fe","repo":"GoogleContainerTools/skaffold","slug":"failed-to-evaluate-container-name-pattern-q-due-t","errorCode":null,"errorMessage":"failed to evaluate container name pattern %q due to error %w","messagePattern":"failed to evaluate container name pattern %q due to error %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/hooks/container.go","lineNumber":74,"sourceCode":"// namePatternSelector chooses containers that match the glob patterns for pod and container names\nfunc namePatternSelector(podName, containerName string) containerSelector {\n\treturn func(p v1.Pod, c v1.Container) (bool, error) {\n\t\tif p.Status.Phase != v1.PodRunning {\n\t\t\treturn false, nil\n\t\t}\n\t\tfor _, status := range p.Status.ContainerStatuses {\n\t\t\tif status.Name == c.Name && status.State.Running == nil {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t}\n\t\tif matched, err := path.Match(podName, p.Name); err != nil {\n\t\t\treturn false, fmt.Errorf(\"failed to evaluate pod name pattern %q due to error %w\", podName, err)\n\t\t} else if podName != \"\" && !matched {\n\t\t\treturn false, nil\n\t\t}\n\n\t\tif matched, err := path.Match(containerName, c.Name); err != nil {\n\t\t\treturn false, fmt.Errorf(\"failed to evaluate container name pattern %q due to error %w\", containerName, err)\n\t\t} else if containerName != \"\" && !matched {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn true, nil\n\t}\n}\n\n// containerHook represents a lifecycle hook to be executed inside a running container\ntype containerHook struct {\n\tcfg        latest.ContainerHook\n\tcli        *kubectl.CLI\n\tselector   containerSelector\n\tnamespaces []string\n\tformatter  logger.Formatter\n}\n\n// run executes the lifecycle hook inside the target container\nfunc (h containerHook) run(ctx context.Context, out io.Writer) error {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/hooks/container.go#L56-L92","documentation":"Identical to the pod-name case but for the container-name selector: when path.Match errors while matching the configured containerName glob against a container's name, the error is wrapped as 'failed to evaluate container name pattern %q due to error %w'.","triggerScenarios":"Running a container hook whose selector's containerName glob is malformed (e.g. 'sidecar-[a-' unclosed character class) while the selector matches pods/containers in containerHook.run.","commonSituations":"Malformed globs in the containerName field of skaffold.yaml container hook selectors; mixing regex syntax into globs; copy-paste errors truncating the closing bracket.","solutions":["Correct the containerName glob so all character classes are closed","Use only path.Match glob syntax: *, ?, and [..] classes","Test the pattern against the expected container name before deploying","Simplify to '*' or an exact name if the pattern is unnecessary"],"exampleFix":"// before\ncontainerName: \"envoy-[proxy\"\n// after\ncontainerName: \"envoy-*\"","handlingStrategy":"validation","validationCode":"func validGlob(p string) bool {\n    _, err := path.Match(p, \"\")\n    return err == nil\n}\nif !validGlob(selector.ContainerName) {\n    return fmt.Errorf(\"malformed containerName glob %q\", selector.ContainerName)\n}","typeGuard":null,"tryCatchPattern":"err := hook.Run(ctx, out)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to evaluate container name pattern\") {\n        return fmt.Errorf(\"fix containerName glob in hook selector: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep containerName patterns simple (* or exact names)","Avoid regex-only constructs in globs","Test patterns with path.Match before committing config"],"tags":["glob","pattern","kubernetes","hooks"],"backgroundTag":"invalid-glob-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"}