{"record":{"id":"81b00ecabfd078b6","repo":"openimsdk/open-im-server","slug":"config-field-s-s-not-found","errorCode":null,"errorMessage":"config field %s %s not found","messagePattern":"config field (.+?) (.+?) not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/main.go","lineNumber":224,"sourceCode":"\t\ttypeField := tof.Field(i)\n\t\tif !typeField.IsExported() {\n\t\t\tcontinue\n\t\t}\n\t\tfield := vof.Field(i)\n\t\tpkt := x.getTypePath(field.Type())\n\t\tval, ok := x.conf[pkt]\n\t\tif !ok {\n\t\t\tswitch field.Interface().(type) {\n\t\t\tcase config.Index:\n\t\t\t\tfield.Set(reflect.ValueOf(config.Index(x.index)))\n\t\t\tcase config.Path:\n\t\t\t\tfield.SetString(x.confPath)\n\t\t\tcase config.AllConfig:\n\t\t\t\tfield.Set(reflect.ValueOf(x.config))\n\t\t\tcase *config.AllConfig:\n\t\t\t\tfield.Set(reflect.ValueOf(&x.config))\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"config field %s %s not found\", vof.Type().Name(), typeField.Name)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tfield.Set(val)\n\t}\n\treturn nil\n}\n\nfunc (x *cmds) add(name string, block bool, fn func(ctx context.Context) error) {\n\tx.cmds = append(x.cmds, cmdName{Name: name, Block: block, Func: fn})\n}\n\nfunc (x *cmds) initLog() error {\n\tconf := x.config.Log\n\tif err := log.InitLoggerFromConfig(\n\t\t\"openim-service-log\",\n\t\tprogram.GetProcessName(),\n\t\t\"\", \"\",","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/openimsdk/open-im-server/blob/175a7bb0673eca18e9d1b10bff4f728da6b1b513/cmd/main.go#L206-L242","documentation":"parseConf uses reflection to populate struct fields from the service's own config (x.config / x.confPath). When the field's declared type does not match any of the supported config kinds (string path, AllConfig, *AllConfig), the reflection switch falls into the default branch and returns this error naming the offending types. It means the configuration struct contains a field the config loader does not know how to inject.","triggerScenarios":"A service config struct declares a field whose type is not config.AllConfig, *config.AllConfig, or a string for the conf path, so typeField.Type hits the default case in the reflect switch during parseConf at startup.","commonSituations":"Adding a custom field to a service config struct; renaming or changing the type of an existing config field after a version upgrade; copying a config struct from another service that had extra fields the loader can't handle.","solutions":["Change the offending struct field's type to config.AllConfig, *config.AllConfig, or string (config path) so the reflection switch can handle it","Add a case to the type switch in parseConf that supports the new field type","Remove or move the unsupported field out of the struct that parseConf fills via reflection"],"exampleFix":"// before\nMyExtra string // unsupported type in parseConf switch -> error\n// after\nimport \"github.com/openimsdk/tools/db/config\"\nAllConfig config.AllConfig // supported by parseConf's type switch","handlingStrategy":"validation","validationCode":"func validateConfFields(cfg interface{}) error {\n\tt := reflect.TypeOf(cfg).Elem()\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tswitch t.Field(i).Type.Name() {\n\t\tcase \"string\", \"AllConfig\":\n\t\tdefault:\n\t\t\tif t.Field(i).Type != reflect.TypeOf(&config.AllConfig{}) {\n\t\t\t\treturn fmt.Errorf(\"unsupported config field type: %s %s\", t.Field(i).Type, t.Field(i).Name)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isSupportedConfigType(t reflect.Type) bool {\n\treturn t.Kind() == reflect.String || t == reflect.TypeOf(config.AllConfig{}) || t == reflect.TypeOf(&config.AllConfig{})\n}","tryCatchPattern":null,"preventionTips":["Only use string, config.AllConfig, or *config.AllConfig as field types in structs filled by parseConf","Run the service once in a dev environment after any config struct change","Keep config structs in sync with upstream releases"],"tags":["configuration","reflection","startup"],"backgroundTag":"unsupported-config-field-type","analyzedSha":"175a7bb0673eca18e9d1b10bff4f728da6b1b513","analyzedAt":"2026-09-04T16:52:56.821Z","contentChangedAt":"2026-09-04T16:52:56.821Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}