golangci/golangci-lint · error

the sort-order name %q is repeated several times

Error message

the sort-order name %q is repeated several times

What it means

This error is thrown during output config validation when the same sort-order name appears more than once in the SortOrder list. The validator joins all entries with spaces and counts occurrences of each name; any count greater than 1 fails. golangci-lint only supports 'linter', 'file', and 'severity' as sort keys, and repeating one makes the ordering ambiguous.

Source

Thrown at pkg/config/output.go:41

	}

	for _, v := range validators {
		if err := v(); err != nil {
			return err
		}
	}

	return nil
}

func (o *Output) validateSortOrder() error {
	validOrders := []string{"linter", "file", "severity"}

	all := strings.Join(o.SortOrder, " ")

	for _, order := range o.SortOrder {
		if strings.Count(all, order) > 1 {
			return fmt.Errorf("the sort-order name %q is repeated several times", order)
		}

		if !slices.Contains(validOrders, order) {
			return fmt.Errorf("unsupported sort-order name %q", order)
		}
	}

	return nil
}

func (o *Output) validatePathMode() error {
	switch o.PathMode {
	case "", fsutils.OutputPathModeAbsolute:
		// Valid

	default:
		return fmt.Errorf("unsupported output path mode %q", o.PathMode)
	}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Remove the duplicated entry from output.sort-order in your config so each of 'linter', 'file', 'severity' appears at most once
  2. Keep only the keys you need in the desired precedence order, e.g. ["file", "linter"]

Example fix

// before
output:
  sort-order:
    - linter
    - severity
    - severity
// after
output:
  sort-order:
    - linter
    - severity
Defensive patterns

Strategy: validation

Validate before calling

orders := cfg.Output.SortOrder
seen := map[string]bool{}
valid := map[string]bool{"linter": true, "file": true, "severity": true}
for _, o := range orders {
  if seen[o] || !valid[o] {
    return fmt.Errorf("invalid or duplicated sort-order %q", o)
  }
  seen[o] = true
}

Prevention

When it happens

Trigger: Setting output.sort-order in the YAML config (e.g. ["severity", "severity"]) or calling Output.Validate() via validateSortOrder with a duplicated name.

Common situations: Copy-pasting a sort key when editing .golangci.yml; merging config fragments that each append the same sort key; forgetting the field is a list of distinct keys.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/90be686fed677e08. Report an issue: GitHub.