AdguardTeam/AdGuardHome · warning

invalid theme %q, supported: %q, %q, %q

Error message

invalid theme %q, supported: %q, %q, %q

What it means

Theme.UnmarshalText rejects a profile theme string that is not 'auto', 'dark', or 'light'. This runs whenever a profile JSON body is decoded — PUT /control/profile/update or reads of /control/profile bodies.

Source

Thrown at internal/home/profilehttp.go:33

//
// Keep in sync with client/src/helpers/constants.ts.
const (
	ThemeAuto  Theme = "auto"
	ThemeLight Theme = "light"
	ThemeDark  Theme = "dark"
)

// UnmarshalText implements [encoding.TextUnmarshaler] interface for *Theme.
func (t *Theme) UnmarshalText(b []byte) (err error) {
	switch string(b) {
	case "auto":
		*t = ThemeAuto
	case "dark":
		*t = ThemeDark
	case "light":
		*t = ThemeLight
	default:
		return fmt.Errorf("invalid theme %q, supported: %q, %q, %q", b, ThemeAuto, ThemeDark, ThemeLight)
	}

	return nil
}

// profileJSON is an object for /control/profile and /control/profile/update
// endpoints.
type profileJSON struct {
	Name     string `json:"name"`
	Language string `json:"language"`
	Theme    Theme  `json:"theme"`
}

// handleGetProfile is the handler for GET /control/profile endpoint.
func (web *webAPI) handleGetProfile(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	var name string

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Send exactly one of "auto", "dark", "light" (lowercase, no whitespace)
  2. Validate the theme on the client before PUTing the profile
  3. If integrating, treat unknown themes as 'auto' rather than forwarding raw user input

Example fix

// before
{"name":"admin","theme":"system"}

// after
{"name":"admin","theme":"auto"}
Defensive patterns

Strategy: type-guard

Validate before calling

var validThemes = map[string]bool{"auto": true, "dark": true, "light": true}
if !validThemes[req.Theme] { req.Theme = "auto" }

Type guard

func isValidTheme(s string) bool {
    switch s { case "auto", "dark", "light": return true }; return false
}

Prevention

When it happens

Trigger: PUT /control/profile/update with "theme": "system", "themes": "dark ", or any casing other than the three exact lowercase values; encoding/json surfaces this as a SyntaxError wrapping this message.

Common situations: Third-party clients or scripts sending theme names the UI never produces, region-locale defaults like '暗色', or values from older API versions.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/0385904f539a668f. Report an issue: GitHub.