{"record":{"id":"768e77126167ad99","repo":"GoogleContainerTools/skaffold","slug":"pattern-error-for-q-w","errorCode":null,"errorMessage":"pattern error for %q: %w","messagePattern":"pattern error for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/sync/sync.go","lineNumber":146,"sourceCode":"\t}\n\n\tsyncMap, err := SyncMap(ctx, a, cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"inferring syncmap for image %q: %w\", a.ImageName, err)\n\t}\n\n\ttoCopy := make(map[string][]string)\n\tfor _, f := range append(e.Modified, e.Added...) {\n\t\trelPath, err := filepath.Rel(a.Workspace, f)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"finding changed file %s relative to context %q: %w\", f, a.Workspace, err)\n\t\t}\n\n\t\tmatches := false\n\t\tfor _, p := range a.Sync.Infer {\n\t\t\tmatches, err = doublestar.PathMatch(filepath.FromSlash(p), relPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"pattern error for %q: %w\", relPath, err)\n\t\t\t}\n\t\t\tif matches {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !matches {\n\t\t\tlog.Entry(ctx).Infof(\"Changed file %s does not match any sync pattern. Skipping sync\", relPath)\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tif dsts, ok := syncMap[relPath]; ok {\n\t\t\ttoCopy[f] = dsts\n\t\t} else {\n\t\t\tlog.Entry(ctx).Infof(\"Changed file %s is not syncable. Skipping sync\", relPath)\n\t\t\treturn nil, nil\n\t\t}\n\t}\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/sync/sync.go#L128-L164","documentation":"During inferred sync, each relative path is tested against the user's `sync.infer` glob patterns with doublestar.PathMatch. If a pattern itself is malformed (e.g. unclosed `[` or `{`), PathMatch returns a syntax error and Skaffold reports it as a pattern error for the file being matched.","triggerScenarios":"A `sync.infer` pattern in skaffold.yaml contains invalid glob syntax — typically an unclosed character class `[`, an unbalanced alternation `{`, or a misplaced `**` — so doublestar.PathMatch errors while matching a changed file's relative path.","commonSituations":"Hand-edited skaffold.yaml infer patterns like `src/**/*.go{1}` or `src/[a-*.go`; patterns copied from Windows shells where `[` was intended literally; templating that injects a half-written glob.","solutions":["Open skaffold.yaml and fix the malformed `sync.infer` glob (close `[...]`/`{...}` groups)","Validate each pattern locally with doublestar.PathMatch or filepath.Match in a scratch Go program, feeding the relPath shown in the error","Escape literal `[` or `{` in filenames with a `[[]` class instead of the raw character"],"exampleFix":"// before\nsync:\n  infer:\n    - src/**/*.go{1   # unbalanced {   \n// after\nsync:\n  infer:\n    - src/**/*.go","handlingStrategy":"validation","validationCode":"for _, p := range a.Sync.Infer {\n    if _, err := doublestar.PathMatch(filepath.FromSlash(p), \"sample.go\"); err != nil {\n        return fmt.Errorf(\"invalid sync.infer pattern %q: %w\", p, err)\n    }\n}","typeGuard":"func validGlob(p string) bool {\n    _, err := doublestar.PathMatch(filepath.FromSlash(p), \"\")\n    return err == nil\n}","tryCatchPattern":"item, err := sync.NewItem(ctx, a, tag, e, cfg, builds)\nif err != nil {\n    if strings.Contains(err.Error(), \"pattern error\") {\n        return fmt.Errorf(\"fix sync.infer glob in skaffold.yaml: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate all sync.infer globs at config-load time, not first sync","Avoid raw [ or { intended literally; escape with [[]","Keep patterns simple (**/*.ext style) and lint skaffold.yaml in CI"],"tags":["skaffold","sync","glob","doublestar","config"],"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"}