{"record":{"id":"0be3175e487e3562","repo":"apache/beam","slug":"invalid-glob-pattern-w","errorCode":null,"errorMessage":"invalid glob pattern: %w","messagePattern":"invalid glob pattern: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/memfs/memory.go","lineNumber":80,"sourceCode":"\treturn instance\n}\n\nfunc (f *fs) Close() error {\n\treturn nil\n}\n\nfunc (f *fs) List(_ context.Context, glob string) ([]string, error) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\n\t// As with other functions, the memfs:// prefix is optional.\n\tglobNoScheme := strings.TrimPrefix(glob, \"memfs://\")\n\n\tvar ret []string\n\tfor k := range f.m {\n\t\tmatched, err := filesystem.Match(globNoScheme, strings.TrimPrefix(k, \"memfs://\"))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid glob pattern: %w\", err)\n\t\t}\n\t\tif matched {\n\t\t\tret = append(ret, k)\n\t\t}\n\t}\n\tsort.Strings(ret)\n\treturn ret, nil\n}\n\nfunc (f *fs) OpenRead(_ context.Context, filename string) (io.ReadCloser, error) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\n\tif v, ok := f.m[normalize(filename)]; ok {\n\t\treturn io.NopCloser(bytes.NewReader(v.Data)), nil\n\t}\n\treturn nil, os.ErrNotExist\n}","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/memfs/memory.go#L62-L98","documentation":"The in-memory filesystem's List matches every stored key against the glob using filesystem.Match; if the glob itself is syntactically invalid, Match returns an error which List wraps as 'invalid glob pattern: %w'. This validates patterns eagerly even when the store is empty.","triggerScenarios":"Calling fs.List(ctx, glob) on a memfs filesystem with a malformed pattern (e.g. unclosed '[' , invalid '**' usage) that filesystem.Match rejects.","commonSituations":"Unit-test fixtures with hand-written bad globs; dynamically generated patterns with truncated bracket classes; mixing GCS-style patterns with memfs semantics.","solutions":["Fix the glob syntax before calling List.","Test the pattern with filesystem.Match directly to get the raw syntax error.","Pre-validate patterns in test helpers to fail with clearer messages.","Avoid shell-specific glob constructs not supported by filesystem.Match."],"exampleFix":"// before\nglob := \"memfs://data[0-9\" // invalid\nfiles, err := fs.List(ctx, glob)\n// after\nglob := \"memfs://data[0-9]*\"\nfiles, err := fs.List(ctx, glob)","handlingStrategy":"validation","validationCode":"if _, err := filesystem.Match(globNoScheme, \"probe\"); err != nil {\n\treturn fmt.Errorf(\"glob %q is invalid: %w\", glob, err)\n}","typeGuard":null,"tryCatchPattern":"files, err := fs.List(ctx, glob)\nif err != nil && strings.Contains(err.Error(), \"invalid glob pattern\") {\n\treturn fmt.Errorf(\"check memfs glob %q: %w\", glob, err)\n}","preventionTips":["Probe the pattern with filesystem.Match in tests before use.","Avoid shell-only glob constructs in memfs patterns.","Strip schemes consistently before validation.","Use simple wildcard patterns where character classes aren't needed."],"tags":["go","apache-beam","memfs","glob","validation"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}