grpc/grpc-go · error

no supported policies found in config: %v

Error message

no supported policies found in config: %v

What it means

Returned by gracefulswitch.ParseConfig after iterating through all entries in the loadBalancingConfig array and finding no registered balancer builder for any policy name. Unregistered names are silently skipped (config.go:65-68: 'Skip unregistered balancer names'), so if every name is unregistered, the loop completes with no match and this error fires.

Source

Thrown at internal/balancer/gracefulswitch/config.go:83

		if builder == nil {
			// Skip unregistered balancer names.
			continue
		}

		parser, ok := builder.(balancer.ConfigParser)
		if !ok {
			// This is a valid child with no config.
			return &lbConfig{childBuilder: builder}, nil
		}

		cfg, err := parser.ParseConfig(jsonCfg)
		if err != nil {
			return nil, fmt.Errorf("error parsing config for policy %q: %v", name, err)
		}
		return &lbConfig{childBuilder: builder, childConfig: cfg}, nil
	}

	return nil, fmt.Errorf("no supported policies found in config: %v", string(cfg))
}

View on GitHub (pinned to 0c51461d27)

Solutions

  1. Verify each policy name is spelled correctly and matches a name registered via balancer.Register()
  2. Import the balancer package for its init side effect: _ "google.golang.org/grpc/balancer/roundrobin"
  3. Check registration at runtime with balancer.Get(name) before relying on it
  4. Print registered balancers if unsure what names are available

Example fix

// before: 'roundrobin' is not the registered name
"loadBalancingConfig": [{"roundrobin":{}}]

// after: 'round_robin' is the registered name
"loadBalancingConfig": [{"round_robin":{}}]

// also ensure the import exists:
import _ "google.golang.org/grpc/balancer/roundrobin"
Defensive patterns

Strategy: validation

Validate before calling

// Check that at least one policy name is registered before calling ParseConfig
func hasRegisteredPolicy(raw json.RawMessage) error {
    var entries []map[string]json.RawMessage
    if err := json.Unmarshal(raw, &entries); err != nil {
        return err
    }
    found := false
    for _, e := range entries {
        for name := range e {
            if balancer.Get(name) != nil {
                found = true
            }
        }
    }
    if !found {
        return fmt.Errorf("no registered balancer found in config")
    }
    return nil
}

Prevention

When it happens

Trigger: Calling ParseConfig with a loadBalancingConfig array where every policy name fails balancer.Get(name) == nil. For example, referencing 'grpclb' when that package is not imported, or using 'roundrobin' (no underscore) instead of the registered 'round_robin'.

Common situations: Forgetting to import a balancer package for its init() side effect (e.g., missing _ "google.golang.org/grpc/balancer/roundrobin"). Using a balancer name from a different gRPC language or version. Typos in policy names in the service config.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/b3c6148babdec911. Report an issue: GitHub.