From ee9c3396281cbee5d15e8fd56231584df3632f98 Mon Sep 17 00:00:00 2001 From: Dan Jaglowski Date: Fri, 22 Sep 2023 09:36:44 -0600 Subject: [PATCH] Log valid feature gates on error --- featuregate/registry.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/featuregate/registry.go b/featuregate/registry.go index ed6cf532e32..e734711082e 100644 --- a/featuregate/registry.go +++ b/featuregate/registry.go @@ -109,7 +109,11 @@ func (r *Registry) Register(id string, stage Stage, opts ...RegisterOption) (*Ga func (r *Registry) Set(id string, enabled bool) error { v, ok := r.gates.Load(id) if !ok { - return fmt.Errorf("no such feature gate %q", id) + validGates := []string{} + r.VisitAll(func(g *Gate) { + validGates = append(validGates, g.ID()) + }) + return fmt.Errorf("no such feature gate %q. valid gates: %v", id, validGates) } g := v.(*Gate)