{"record":{"id":"246c1a03ce7f3797","repo":"oauth2-proxy/oauth2-proxy","slug":"unable-to-register-flags-w","errorCode":null,"errorMessage":"unable to register flags: %w","messagePattern":"unable to register flags: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/options/load.go","lineNumber":45,"sourceCode":"func Load(configFileName string, flagSet *pflag.FlagSet, into interface{}) error {\n\tv := viper.New()\n\tv.SetConfigFile(configFileName)\n\tv.SetConfigType(\"toml\") // Config is in toml format\n\tv.SetEnvPrefix(\"OAUTH2_PROXY\")\n\tv.AutomaticEnv()\n\tv.SetTypeByDefaultValue(true)\n\n\tif configFileName != \"\" {\n\t\terr := v.ReadInConfig()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to load config file: %w\", err)\n\t\t}\n\t}\n\n\terr := registerFlags(v, \"\", flagSet, into)\n\tif err != nil {\n\t\t// This should only happen if there is a programming error\n\t\treturn fmt.Errorf(\"unable to register flags: %w\", err)\n\t}\n\n\t// UnmarshalExact will return an error if the config includes options that are\n\t// not mapped to fields of the into struct\n\terr = v.UnmarshalExact(into, decodeFromCfgTag)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error unmarshalling config: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// LoadYAML will load a YAML based configuration file into the options interface provided.\nfunc LoadYAML(configFileName string, opts interface{}) error {\n\tbuffer, err := loadAndSubstituteEnvs(configFileName)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/oauth2-proxy/oauth2-proxy/blob/33c2eb92dea78204f7a18bc2dfdbccc220f39257/pkg/apis/options/load.go#L27-L63","documentation":"Wrap error in options.Load: reflectively registering config/flags onto the target options struct failed. Per the adjacent comment this should only happen on a programming error (struct field missing required cfg/flag tags), not from user input.","triggerScenarios":"Thrown at pkg/apis/options/load.go:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as a developer error: verify newly added Options fields have both cfg and flag tags","Revert recent changes to the options structs if this appears after an upgrade","Check nested struct fields carry the ,squash cfg tag"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"33c2eb92dea78204f7a18bc2dfdbccc220f39257","analyzedAt":"2026-09-06T08:51:53.077Z","contentChangedAt":"2026-09-06T08:51:53.077Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}