spicetify/cli · error

unrecognized theme assets kind. only "root", "folder", "colo

Error message

unrecognized theme assets kind. only "root", "folder", "color", "css", "js" or "assets" is valid

What it means

ThemeAssetPath only recognizes the kinds "root", "folder", "color", "css", "js" and "assets". Any other kind string falls through all branches and returns this error from src/cmd/path.go, acting as a strict enum guard on the kind parameter.

Source

Thrown at src/cmd/path.go:37

	}

	if kind == "folder" {
		return themeFolder, nil
	} else if kind == "color" {
		color := filepath.Join(themeFolder, "color.ini")
		return color, nil
	} else if kind == "css" {
		css := filepath.Join(themeFolder, "user.css")
		return css, nil
	} else if kind == "js" {
		js := filepath.Join(themeFolder, "theme.js")
		return js, nil
	} else if kind == "assets" {
		assets := filepath.Join(themeFolder, "assets")
		return assets, nil
	}

	return "", errors.New(`unrecognized theme assets kind. only "root", "folder", "color", "css", "js" or "assets" is valid`)
}

// ThemeAllAssetsPath returns paths of all theme's assets
func ThemeAllAssetsPath() (string, error) {
	InitSetting()

	if len(themeFolder) == 0 {
		return "", errors.New(`config "current_theme" is blank`)
	}

	results := []string{
		themeFolder,
		filepath.Join(themeFolder, "color.ini"),
		filepath.Join(themeFolder, "user.css"),
		filepath.Join(themeFolder, "theme.js"),
		filepath.Join(themeFolder, "assets")}

	return strings.Join(results, "\n"), nil

View on GitHub (pinned to 1f13f73616)

Solutions

  1. Pass exactly one of: root, folder, color, css, js, assets (lowercase)
  2. Normalize/validate the kind string before calling
  3. For all theme asset paths at once, use ThemeAllAssetsPath instead

Example fix

// before
path, err := cmd.ThemeAssetPath("CSS")
// after
path, err := cmd.ThemeAssetPath("css")
Defensive patterns

Strategy: validation

Validate before calling

validKinds := map[string]bool{"root": true, "folder": true, "color": true, "css": true, "js": true, "assets": true}
k := strings.ToLower(kind)
if !validKinds[k] {
    return fmt.Errorf("kind must be one of root, folder, color, css, js, assets; got %q", kind)
}

Type guard

type ThemeAssetKind string
func (k ThemeAssetKind) valid() bool {
    switch k {
    case "root", "folder", "color", "css", "js", "assets":
        return true
    }
    return false
}

Prevention

When it happens

Trigger: Calling ThemeAssetPath with a misspelled or unsupported kind such as "Color", "styles", "cssfile", or an empty string — i.e. the kind matched none of the six literal comparisons in the function.

Common situations: Programmatic callers passing user-supplied kind values without normalization; case-sensitivity mistakes ("CSS"); calling with "path" or "all" expecting an alias that does not exist.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of spicetify/cli@1f13f73616 (2026-08-31). Data as JSON: /api/errors/70e9adead185390c. Report an issue: GitHub.