{"record":{"id":"c451199f6c9a4c73","repo":"GoogleContainerTools/skaffold","slug":"failed-to-evaluate-pod-name-pattern-q-due-to-erro","errorCode":null,"errorMessage":"failed to evaluate pod name pattern %q due to error %w","messagePattern":"failed to evaluate pod name pattern %q due to error %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/hooks/container.go","lineNumber":68,"sourceCode":"\t\t}\n\n\t\treturn c.Image == image, nil\n\t}\n}\n\n// 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","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/hooks/container.go#L50-L86","documentation":"Container lifecycle hooks select target pods/containers using glob-style patterns matched with path.Match. If evaluating the pod-name pattern itself returns an error (path.Match only errors on malformed patterns, e.g. unclosed '['), the failure is wrapped as 'failed to evaluate pod name pattern %q due to error %w'.","triggerScenarios":"Running a container hook whose selector's podName glob is malformed — e.g. 'mypod-[abc' with an unterminated character class — while iterating pods in containerHook.run via h.selector(p, c).","commonSituations":"Hand-written glob patterns in skaffold.yaml container hooks with unbalanced brackets; patterns copied from regex syntax (using constructs path.Match doesn't support); typos like 'pod-*-[0-9' missing the closing bracket.","solutions":["Fix the podName pattern to be a valid glob: close all '[' ... ']' character classes","Remove regex-only syntax (path.Match supports only * ? [class] and no alternation)","Test the pattern with a quick Go snippet or shell: path.Match(pattern, podName)","Escape literal '[' in pod names if that character is intended to match literally"],"exampleFix":"// before (skaffold.yaml container hook selector)\npodName: \"myapp-[abc\"\n// after\npodName: \"myapp-[abc]\"        // valid character class\n# or simply\npodName: \"myapp-*\"            # plain glob","handlingStrategy":"validation","validationCode":"func validGlob(p string) bool {\n    _, err := path.Match(p, \"\")\n    return err == nil\n}\nif !validGlob(selector.PodName) {\n    return fmt.Errorf(\"malformed podName glob %q\", selector.PodName)\n}","typeGuard":null,"tryCatchPattern":"err := hook.Run(ctx, out)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to evaluate pod name pattern\") {\n        return fmt.Errorf(\"fix podName glob in hook selector: %w\", err)\n    }\n    return err\n}","preventionTips":["Use only glob syntax (* ? [..]) not regex in selectors","Close all [ ] character classes","Unit-test selector globs against expected pod names"],"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"}