{"record":{"id":"4655de68a2cba881","repo":"micro-editor/micro","slug":"error-setting-s-has-incorrect-type-s-using","errorCode":null,"errorMessage":"Error: setting '%s' has incorrect type (%s), using default value: %v (%s)","messagePattern":"Error: setting '(.+?)' has incorrect type \\((.+?)\\), using default value: (.+?) \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/settings.go","lineNumber":289,"sourceCode":"\t\ts[k] = v\n\t}\n\treturn s\n}\n\nfunc verifySetting(option string, value any, def any) error {\n\tvar interfaceArr []any\n\tvalType := reflect.TypeOf(value)\n\tdefType := reflect.TypeOf(def)\n\tassignable := false\n\n\tswitch option {\n\tcase \"pluginrepos\", \"pluginchannels\":\n\t\tassignable = valType.AssignableTo(reflect.TypeOf(interfaceArr))\n\tdefault:\n\t\tassignable = defType.AssignableTo(valType)\n\t}\n\tif !assignable {\n\t\treturn fmt.Errorf(\"Error: setting '%s' has incorrect type (%s), using default value: %v (%s)\", option, valType, def, defType)\n\t}\n\n\tif option == \"colorscheme\" {\n\t\t// Plugins are not initialized yet, so do not verify if the colorscheme\n\t\t// exists yet, since the colorscheme may be added by a plugin later.\n\t\treturn nil\n\t}\n\n\tif err := OptionIsValid(option, value); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// InitGlobalSettings initializes the options map and sets all options to their default values\n// Must be called after ReadSettings\nfunc InitGlobalSettings() error {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/micro-editor/micro/blob/1c8b82b32e408a5faf340039ed92d5266bea3293/internal/config/settings.go#L271-L307","documentation":"This error is returned by verifyOption in internal/config/settings.go when the value read from settings.json (or passed to set) has a Go type that does not match the type of the option's registered default. The message reports the offending option name, the actual reflect type of the value, and the default value plus its type that will be used instead. Note that 'pluginrepos' and 'pluginchannels' are special-cased: their value must be a JSON array ([]any), not a plain string.","triggerScenarios":"Writing settings.json manually with a wrong JSON type, e.g. \"tabsize\": \"4\" (string instead of number), \"pluginrepos\": \"https://...\" (string instead of array), \"softwrap\": \"true\" (string instead of boolean), or \"colorscheme\": 3. Also triggered by the >set command when the parsed value's type diverges from the default's type.","commonSituations":"Editing settings.json by hand and quoting numbers or booleans (JSON habit from other tools); copy-pasting config snippets from tutorials written for a different micro version where an option's type changed; splitting a single repo URL into pluginrepos without wrapping it in [ ... ]; using YAML-style true instead of JSON true.","solutions":["Fix the type in ~/.config/micro/settings.json so it matches the default type shown in the error (e.g. \"tabsize\": 4, \"pluginrepos\": [\"https://github.com/...\"])","Wrap pluginrepos/pluginchannels values in JSON array brackets [ ... ]","If unsure of the expected type, delete the option from settings.json and let micro regenerate it with the default, or check the option's default with >set optionname and observe the type","Restart micro or reload the config after fixing the file"],"exampleFix":"// settings.json — before\n{\n  \"tabsize\": \"4\",\n  \"pluginrepos\": \"https://github.com/micro-editor/plugin-channel\"\n}\n// after\n{\n  \"tabsize\": 4,\n  \"pluginrepos\": [\"https://github.com/micro-editor/plugin-channel\"]\n}","handlingStrategy":"validation","validationCode":"// Before writing the option, mirror the type check\ncfgDefault, exists := config.DefaultGlobalSettings[option]\nif exists {\n    want := reflect.TypeOf(cfgDefault)\n    got := reflect.TypeOf(value)\n    ok := false\n    if option == \"pluginrepos\" || option == \"pluginchannels\" {\n        ok = got.AssignableTo(reflect.TypeOf([]any{}))\n    } else if want != nil {\n        ok = got.AssignableTo(want)\n    }\n    if !ok {\n        return fmt.Errorf(\"option %s: want %v, got %v\", option, want, got)\n    }\n}","typeGuard":"func matchesDefaultType(option string, v any) bool {\n    def, ok := config.DefaultGlobalSettings[option]\n    if !ok {\n        return true // unregistered options are not type-checked\n    }\n    if option == \"pluginrepos\" || option == \"pluginchannels\" {\n        _, isSlice := v.([]any)\n        return isSlice\n    }\n    return reflect.TypeOf(v).AssignableTo(reflect.TypeOf(def))\n}","tryCatchPattern":null,"preventionTips":["Validate settings.json with a JSON schema or jq before launching micro","Never quote numbers or booleans in settings.json","When generating config programmatically, marshal a struct with typed fields instead of map[string]any"],"tags":["config","settings","type-mismatch","json"],"backgroundTag":null,"analyzedSha":"1c8b82b32e408a5faf340039ed92d5266bea3293","analyzedAt":"2026-08-15T20:01:45.134Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}