micro-editor/micro · error

Error: setting '%s' has incorrect type (%s), using default v

Error message

Error: setting '%s' has incorrect type (%s), using default value: %v (%s)

What it means

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.

Source

Thrown at internal/config/settings.go:289

		s[k] = v
	}
	return s
}

func verifySetting(option string, value any, def any) error {
	var interfaceArr []any
	valType := reflect.TypeOf(value)
	defType := reflect.TypeOf(def)
	assignable := false

	switch option {
	case "pluginrepos", "pluginchannels":
		assignable = valType.AssignableTo(reflect.TypeOf(interfaceArr))
	default:
		assignable = defType.AssignableTo(valType)
	}
	if !assignable {
		return fmt.Errorf("Error: setting '%s' has incorrect type (%s), using default value: %v (%s)", option, valType, def, defType)
	}

	if option == "colorscheme" {
		// Plugins are not initialized yet, so do not verify if the colorscheme
		// exists yet, since the colorscheme may be added by a plugin later.
		return nil
	}

	if err := OptionIsValid(option, value); err != nil {
		return err
	}

	return nil
}

// InitGlobalSettings initializes the options map and sets all options to their default values
// Must be called after ReadSettings
func InitGlobalSettings() error {

View on GitHub (pinned to 1c8b82b32e)

Solutions

  1. 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/..."])
  2. Wrap pluginrepos/pluginchannels values in JSON array brackets [ ... ]
  3. 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
  4. Restart micro or reload the config after fixing the file

Example fix

// settings.json — before
{
  "tabsize": "4",
  "pluginrepos": "https://github.com/micro-editor/plugin-channel"
}
// after
{
  "tabsize": 4,
  "pluginrepos": ["https://github.com/micro-editor/plugin-channel"]
}
Defensive patterns

Strategy: validation

Validate before calling

// Before writing the option, mirror the type check
cfgDefault, exists := config.DefaultGlobalSettings[option]
if exists {
    want := reflect.TypeOf(cfgDefault)
    got := reflect.TypeOf(value)
    ok := false
    if option == "pluginrepos" || option == "pluginchannels" {
        ok = got.AssignableTo(reflect.TypeOf([]any{}))
    } else if want != nil {
        ok = got.AssignableTo(want)
    }
    if !ok {
        return fmt.Errorf("option %s: want %v, got %v", option, want, got)
    }
}

Type guard

func matchesDefaultType(option string, v any) bool {
    def, ok := config.DefaultGlobalSettings[option]
    if !ok {
        return true // unregistered options are not type-checked
    }
    if option == "pluginrepos" || option == "pluginchannels" {
        _, isSlice := v.([]any)
        return isSlice
    }
    return reflect.TypeOf(v).AssignableTo(reflect.TypeOf(def))
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of micro-editor/micro@1c8b82b32e (2026-08-15). Data as JSON: /api/errors/4655de68a2cba881. Report an issue: GitHub.