{"record":{"id":"9a0e90ded51d2fcb","repo":"thanos-io/thanos","slug":"groupname-should-not-be-empty","errorCode":null,"errorMessage":"Groupname should not be empty","messagePattern":"Groupname should not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rules/manager.go","lineNumber":253,"sourceCode":"\tdelete(native, \"partial_response_strategy\")\n\n\tg.nativeRuleGroup = native\n\treturn nil\n}\n\nfunc (g configRuleAdapter) MarshalYAML() (any, error) {\n\treturn struct {\n\t\tRuleGroup map[string]any `yaml:\",inline\"`\n\t}{\n\t\tRuleGroup: g.nativeRuleGroup,\n\t}, nil\n}\n\n// TODO(bwplotka): Replace this with upstream implementation after https://github.com/prometheus/prometheus/issues/7128 is fixed.\nfunc (g configRuleAdapter) validate() (errs []error) {\n\tset := map[string]struct{}{}\n\tif g.group.Name == \"\" {\n\t\terrs = append(errs, errors.New(\"Groupname should not be empty\"))\n\t}\n\n\tif _, ok := set[g.group.Name]; ok {\n\t\terrs = append(\n\t\t\terrs,\n\t\t\tfmt.Errorf(\"groupname: %q is repeated in the same file\", g.group.Name),\n\t\t)\n\t}\n\n\tset[g.group.Name] = struct{}{}\n\n\tfor i, r := range g.group.Rules {\n\t\tfor _, node := range r.Validate(rulefmt.RuleNode{}, model.UTF8Validation) {\n\t\t\tvar ruleName string\n\t\t\tif r.Alert != \"\" {\n\t\t\t\truleName = r.Alert\n\t\t\t} else {\n\t\t\t\truleName = r.Record","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/rules/manager.go#L235-L271","documentation":"configRuleAdapter.validate performs extra checks beyond upstream Prometheus validation; here it collects an error when a rule group's Name field is empty, since group names must be unique and addressable within a file.","triggerScenarios":"A rule group in a loaded rule file omits the name: field, producing a RuleGroup with empty Name during manager Update/reload.","commonSituations":"Copy-pasting a rule file and deleting the group name; generating rule YAML programmatically without setting name; minimal test fixtures missing name.","solutions":["Add a non-empty name to every rule group in the file","Run promtool check rules to catch this before Thanos reloads","If generating YAML, validate name != \"\" before writing","Check logs for the file path that failed validation and fix that file"],"exampleFix":"// before\ngroups:\n  - rules:\n      - record: job:up\n        expr: up\n// after\ngroups:\n  - name: availability\n    rules:\n      - record: job:up\n        expr: up","handlingStrategy":"validation","validationCode":"for _, g := range cfg.Groups {\n    if g.Name == \"\" {\n        return fmt.Errorf(\"rule group in %s has empty name\", file)\n    }\n}","typeGuard":null,"tryCatchPattern":"errs := group.validate()\nif len(errs) > 0 {\n    for _, e := range errs { log.Error(e) }\n    return errs[0] // or aggregate\n}","preventionTips":["Add name: to every rule group; treat it as required in templates","Run promtool check rules before deployment","Reject empty group names in any YAML generator you own"],"tags":["validation","rules","config"],"backgroundTag":"empty-required-field","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"}