{"record":{"id":"bf49b991b92e9f92","repo":"gohugoio/hugo","slug":"failed-to-create-filter-for-s-w","errorCode":null,"errorMessage":"failed to create filter for %s: %w","messagePattern":"failed to create filter for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/sitesmatrix/vectorstores.go","lineNumber":808,"sourceCode":"\t\t\tswitch cfg.ApplyDefaults {\n\t\t\tcase IntSetsConfigApplyDefaultsIfNotSet:\n\t\t\t\tresult.Set(matcher.IndexDefault())\n\t\t\tcase IntSetsConfigApplyDefaultsAndAllLanguagesIfNotSet:\n\t\t\t\tif what == \"languages\" {\n\t\t\t\t\tfor i := range matcher.ForEachIndex() {\n\t\t\t\t\t\tresult.Set(i)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tresult.Set(matcher.IndexDefault())\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result, nil\n\t\t}\n\n\t\tfilter, err := predicate.NewIndexStringPredicateFromGlobsAndRanges(values, matcher.ResolveIndex, hglob.GetGlobDot)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create filter for %s: %w\", what, err)\n\t\t}\n\t\titer, err := matcher.IndexMatch(filter)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to match %s %q: %w\", what, values, err)\n\t\t}\n\t\tfor i := range iter {\n\t\t\tif result == nil {\n\t\t\t\tresult = hmaps.NewOrderedIntSet()\n\t\t\t}\n\t\t\tresult.Set(i)\n\t\t}\n\n\t\treturn result, nil\n\t}\n\n\tl, err1 := applyFilter(\"languages\", cfg.Globs.Languages, b.cfg.ConfiguredLanguages)\n\tv, err2 := applyFilter(\"versions\", cfg.Globs.Versions, b.cfg.ConfiguredVersions)\n\tr, err3 := applyFilter(\"roles\", cfg.Globs.Roles, b.cfg.ConfiguredRoles)","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/sitesmatrix/vectorstores.go#L790-L826","documentation":"While building an IntSets filter for a dimension (languages/versions/roles), NewIndexStringPredicateFromGlobsAndRanges failed to compile the provided glob/range patterns (vectorstores.go:806-808). This means the glob or range expression syntax itself is invalid, before any matching is attempted.","triggerScenarios":"Passing a malformed glob (unbalanced brackets, invalid range like '1-5-9') in cfg.Globs.Languages/Versions/Roles; a character sequence the glob compiler rejects. The 'what' field names which dimension failed.","commonSituations":"Typing a version range filter with bad syntax in config; copy-pasting a glob from a shell that uses characters Hugo's matcher disallows; programmatically assembling filter strings with unescaped special chars.","solutions":["Check the value of cfg.Globs for the failing dimension (named in the error) and correct the glob/range syntax.","Validate each pattern with the same glob library before feeding it to WithConfig.","Simplify the filter to isolate the offending token, then rebuild incrementally."],"exampleFix":"// before\ncfg.Globs.Versions = []string{\"1..0..0\", \"[invalid\"}\n\n// after\ncfg.Globs.Versions = []string{\"1.0.0\", \"v2.*\"}","handlingStrategy":"validation","validationCode":"// Pre-compile glob patterns to surface syntax errors before WithConfig.\nfunc validateGlobs(patterns []string, resolve func(string) (int, error)) error {\n    for _, p := range patterns {\n        if _, err := predicate.NewIndexStringPredicateFromGlobsAndRanges([]string{p}, resolve, hglob.GetGlobDot); err != nil {\n            return fmt.Errorf(\"invalid glob %q: %w\", p, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate glob/range syntax with the predicate library before building filters.","Restrict user-supplied filter input to a documented glob syntax.","Unit-test filter patterns against known dimension members."],"tags":["sitesmatrix","filter","glob","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}