{"record":{"id":"63f835f29253354b","repo":"kubernetes/kops","slug":"flag-s-not-found","errorCode":null,"errorMessage":"flag %s not found","messagePattern":"flag (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/featureflag/featureflag.go","lineNumber":203,"sourceCode":"\t\t\tparsed++\n\t\t} else {\n\t\t\tklog.Infof(\"Unknown FeatureFlag %q\", s)\n\t\t\tunknown++\n\t\t}\n\t}\n\tif f != \"\" {\n\t\tklog.Infof(\"ParseFlags: parsed %d flags from %q (unknown=%d, registered=%d)\", parsed, f, unknown, len(flags))\n\t}\n}\n\n// Get returns given FeatureFlag.\nfunc Get(flagName string) (*FeatureFlag, error) {\n\tflagsMutex.Lock()\n\tdefer flagsMutex.Unlock()\n\n\tflag, found := flags[flagName]\n\tif !found {\n\t\treturn nil, fmt.Errorf(\"flag %s not found\", flagName)\n\t}\n\treturn flag, nil\n}\n","sourceCodeStart":185,"sourceCodeEnd":207,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/featureflag/featureflag.go#L185-L207","documentation":"featureflag.Get looks up a registered FeatureFlag by name in the global flags map and returns this error when no flag with that name has been registered. Feature flags must first be created (e.g. via featureflag.CreateFlag or a spec-based registration) before Get can retrieve them. Note that ParseFlags logs unknown flags instead of failing, so this error surfaces mainly from direct Get calls.","triggerScenarios":"Calling featureflag.Get(\"SomeFlag\") when the flag was never registered via CreateFlag/New in the process; a typo in the flag name (lookup is by exact string); calling Get before the package or command that registers the flag has run its init(); using a flag that was renamed or removed in a kops version change.","commonSituations":"Custom tooling importing kops' featureflag package and querying a kops-internal flag that isn't registered in that binary; tests enabling flags via the KOPS_FEATURE_FLAGS env var where the name is misspelled (ParseFlags logs \"Unknown FeatureFlag\" and Get then fails); upgrading kops and referencing a flag that no longer exists.","solutions":["Check the exact flag name against the registered flags (grep for CreateFlag/spec registrations in pkg/featureflag) — the lookup is case-sensitive and exact.","Register the flag before calling Get, e.g. featureflag.CreateFlag(\"MyFlag\", true) in an init() or setup path that is guaranteed to run.","If setting via the KOPS_FEATURE_FLAGS environment variable, correct any misspelled names; unknown names are only logged at parse time but Get will fail.","If migrating across kops versions, verify the flag still exists or use its replacement."],"exampleFix":"// before: calling Get for an unregistered/misspelled flag\nff, err := featureflag.Get(\"EnableSeparateEtcd\")\n// after: register first, then Get (or check registration)\nfeatureflag.CreateFlag(\"EnableSeparateEtcd\", false)\nff, err := featureflag.Get(\"EnableSeparateEtcd\")","handlingStrategy":"try-catch","validationCode":"// ensure the flag is registered before Get\nfeatureflag.CreateFlag(\"MyFlag\", true) // idempotent registration in init()/setup\nff, err := featureflag.Get(\"MyFlag\")","typeGuard":null,"tryCatchPattern":"// treat lookup failure as \"flag unavailable\", fall back to default\nff, err := featureflag.Get(\"MyFlag\")\nif err != nil {\n    klog.V(2).Infof(\"feature flag MyFlag not registered, using default: %v\", err)\n    enabled = false\n} else {\n    enabled = ff.Enabled()\n}","preventionTips":["Register all flags in package init() so they exist before any Get call.","Copy flag names exactly; the lookup is case-sensitive with no fuzzy matching.","After upgrading kops, verify each referenced flag still exists.","When enabling via KOPS_FEATURE_FLAGS, watch for the \"Unknown FeatureFlag\" log line as an early warning."],"tags":["feature-flag","kops","config","lookup"],"backgroundTag":"feature-flag-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}