{"record":{"id":"70cb3e6585221acf","repo":"thanos-io/thanos","slug":"error-matching-tenant-pattern-s-tenant-s-w","errorCode":null,"errorMessage":"error matching tenant pattern %s (tenant %s): %w","messagePattern":"error matching tenant pattern (.+?) \\(tenant (.+?)\\): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/hashring.go","lineNumber":264,"sourceCode":"\t}\n\n\tendpointIndex := c.sections[i].replicas[n]\n\treturn c.endpoints[endpointIndex], nil\n}\n\ntype tenantSet map[string]tenantMatcher\n\nfunc (t tenantSet) match(tenant string) (bool, error) {\n\t// Fast path for the common case of direct match.\n\tif mt, ok := t[tenant]; ok && isExactMatcher(mt) {\n\t\treturn true, nil\n\t} else {\n\t\tfor tenantPattern, matcherType := range t {\n\t\t\tswitch matcherType {\n\t\t\tcase TenantMatcherGlob:\n\t\t\t\tmatches, err := filepath.Match(tenantPattern, tenant)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, fmt.Errorf(\"error matching tenant pattern %s (tenant %s): %w\", tenantPattern, tenant, err)\n\t\t\t\t}\n\t\t\t\tif matches {\n\t\t\t\t\treturn true, nil\n\t\t\t\t}\n\t\t\tcase TenantMatcherTypeExact:\n\t\t\t\t// Already checked above, skipping.\n\t\t\t\tfallthrough\n\t\t\tdefault:\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t}\n\t}\n\treturn false, nil\n}\n\n// multiHashring represents a set of hashrings.\n// Which hashring to use for a tenant is determined","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/hashring.go#L246-L282","documentation":"This error wraps a filepath.Match failure that occurs while testing a tenant name against a glob-style tenant matcher in the receive hashring configuration. filepath.Match only fails when the pattern itself is malformed (e.g. unterminated '[' or unclosed escape), so this error indicates a bad glob pattern in the tenant matcher config, not a matching miss.","triggerScenarios":"A hashring is configured with tenants using a glob matcher (TenantMatcherGlob) whose pattern string is a syntactically invalid glob, e.g. '[abc' or 'tenant[*'. The malformed pattern is hit while iterating tenant matchers in multiHashring/matchTenant.","commonSituations":"Hand-edited hashring YAML with typos in tenant patterns; dynamically generated patterns from template expansion that produced unbalanced brackets; copying shell-style globs that filepath.Match rejects.","solutions":["Check the wrapped error from filepath.Match to find the offending pattern and the byte offset of the syntax problem","Fix the glob syntax in the tenant matcher config (balance brackets, avoid dangling escapes)","If the intent was a literal tenant name, use TenantMatcherTypeExact instead of a glob matcher","Add validation of tenant patterns at config-load time (filepath.Match against a sentinel string) to fail fast"],"exampleFix":"// before\ntenants:\n  - '[abc'\n// after\ntenants:\n  - '[abc]'   # or use exact matching for literal names\nmatcher: glob","handlingStrategy":"validation","validationCode":"func validGlob(p string) bool {\n    _, err := filepath.Match(p, \"__probe__\")\n    return err == nil\n}\nfor _, pat := range tenantPatterns {\n    if !validGlob(pat) { return fmt.Errorf(\"invalid tenant glob: %s\", pat) }\n}","typeGuard":null,"tryCatchPattern":"if _, err := filepath.Match(pattern, tenant); err != nil {\n    return false, fmt.Errorf(\"bad tenant pattern %q: %w\", pattern, err)\n}","preventionTips":["Validate all glob patterns at config-load time","Prefer exact matchers for literal tenant names","Add unit tests covering every configured pattern"],"tags":["hashring","glob-pattern","config"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}