micro-editor/micro · error

Invalid value

Error message

Invalid value

What it means

Sentinel error config.ErrInvalidValue from config.GetNativeValue when the string value cannot be parsed into the option's existing type: booleans go through util.ParseBool (accepts true/false/1/0/t/f variants — not 'yes'/'on'), numbers through strconv.ParseFloat, and any other underlying kind fails by default. The option name is valid; the value is not.

Source

Thrown at internal/config/settings.go:146

	"pluginrepos":    []string{},
	"savehistory":    true,
	"scrollbarchar":  "|",
	"sucmd":          "sudo",
	"tabalways":      false,
	"tabhighlight":   false,
	"tabreverse":     true,
	"xterm":          false,
}

// a list of settings that should never be globally modified
var LocalSettings = []string{
	"filetype",
	"readonly",
}

var (
	ErrInvalidOption    = errors.New("Invalid option")
	ErrInvalidValue     = errors.New("Invalid value")
	ErrOptNotToggleable = errors.New("Option not toggleable")

	// The options that the user can set
	GlobalSettings map[string]any

	// This is the raw parsed json
	parsedSettings     map[string]any
	settingsParseError bool

	// ModifiedSettings is a map of settings which should be written to disk
	// because they have been modified by the user in this session
	ModifiedSettings map[string]bool

	// VolatileSettings is a map of settings which should not be written to disk
	// because they have been temporarily set for this session only
	VolatileSettings map[string]bool
)

View on GitHub (pinned to 1c8b82b32e)

Solutions

  1. Use literal booleans: `set autosave true` / `set autosave false` (or 1/0).
  2. Use bare numbers for numeric options: `set tabsize 4`.
  3. In settings.json keep native JSON types: "autosave": true, "tabsize": 4 — not quoted strings for numbers.
  4. Programmatic: call config.GetNativeValue(name, value) first and handle ErrInvalidValue before applying.

Example fix

; before:
> set autosave on        ; error: Invalid value

; after:
> set autosave true
Defensive patterns

Strategy: validation

Validate before calling

func valueMatchesOption(name, strVal string) bool {
    cur := config.GetGlobalOption(name)
    if cur == nil {
        return false
    }
    switch reflect.TypeOf(cur).Kind() {
    case reflect.Bool:
        _, e := strconv.ParseBool(strVal); return e == nil
    case reflect.Float64:
        _, e := strconv.ParseFloat(strVal, 64); return e == nil
    case reflect.String:
        return true
    }
    return false
}

Try / catch

native, err := config.GetNativeValue(name, strVal)
if err != nil {
    if errors.Is(err, config.ErrInvalidValue) {
        // show expected type: bool -> true/false, number -> digits, keep old value
    }
}

Prevention

When it happens

Trigger: `set autosave yes` or `set softwrap on` (ParseBool rejects 'yes'/'on'), `set tabsize four` (ParseFloat fails), or `set colorscheme 123` where the value parses but a later validator rejects it. Raised at internal/config/settings.go:146 via 511/519/523.

Common situations: Users writing YAML-ish booleans ('yes'/'no', 'on'/'off') in the command bar or in scripts, and JSON settings files where a boolean was quoted ("true" as string is fine for strings but numbers quoted like "2" for float options go through this parse and pass — while non-numeric strings fail).

Related errors


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