thanos-io/thanos · error

Groupname should not be empty

Error message

Groupname should not be empty

What it means

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.

Solutions

  1. Add a non-empty name to every rule group in the file
  2. Run promtool check rules to catch this before Thanos reloads
  3. If generating YAML, validate name != "" before writing
  4. Check logs for the file path that failed validation and fix that file

Example fix

// before
groups:
  - rules:
      - record: job:up
        expr: up
// after
groups:
  - name: availability
    rules:
      - record: job:up
        expr: up
Defensive patterns

Strategy: validation

Validate before calling

for _, g := range cfg.Groups {
    if g.Name == "" {
        return fmt.Errorf("rule group in %s has empty name", file)
    }
}

Try / catch

errs := group.validate()
if len(errs) > 0 {
    for _, e := range errs { log.Error(e) }
    return errs[0] // or aggregate
}

Prevention

When it happens

Trigger: A rule group in a loaded rule file omits the name: field, producing a RuleGroup with empty Name during manager Update/reload.

Common situations: Copy-pasting a rule file and deleting the group name; generating rule YAML programmatically without setting name; minimal test fixtures missing name.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/9a0e90ded51d2fcb. Report an issue: GitHub.

Appendix: source

Thrown at pkg/rules/manager.go:253

	delete(native, "partial_response_strategy")

	g.nativeRuleGroup = native
	return nil
}

func (g configRuleAdapter) MarshalYAML() (any, error) {
	return struct {
		RuleGroup map[string]any `yaml:",inline"`
	}{
		RuleGroup: g.nativeRuleGroup,
	}, nil
}

// TODO(bwplotka): Replace this with upstream implementation after https://github.com/prometheus/prometheus/issues/7128 is fixed.
func (g configRuleAdapter) validate() (errs []error) {
	set := map[string]struct{}{}
	if g.group.Name == "" {
		errs = append(errs, errors.New("Groupname should not be empty"))
	}

	if _, ok := set[g.group.Name]; ok {
		errs = append(
			errs,
			fmt.Errorf("groupname: %q is repeated in the same file", g.group.Name),
		)
	}

	set[g.group.Name] = struct{}{}

	for i, r := range g.group.Rules {
		for _, node := range r.Validate(rulefmt.RuleNode{}, model.UTF8Validation) {
			var ruleName string
			if r.Alert != "" {
				ruleName = r.Alert
			} else {
				ruleName = r.Record

View on GitHub (pinned to 35b8b99117)