yorukot/superfile · error
could not unmarshal user's theme file(%s) : %w
Error message
could not unmarshal user's theme file(%s) : %w
What it means
LoadUserTheme unmarshals the theme file bytes as TOML; this error wraps any toml.Unmarshal failure. It means the file was read successfully but its contents are not valid TOML or contain fields/shape incompatible with ThemeType.
Source
Thrown at src/internal/common/load_config.go:218
// Validations
if len(Theme.GradientColor) != RequiredGradientColorCount {
utils.PrintlnAndExit(
LoadThemeError(
"gradient_color",
"Gradient color must contain exactly two values.",
),
)
}
}
func LoadUserTheme(themeFile string, obj *ThemeType) error {
data, err := os.ReadFile(themeFile)
if err != nil {
return fmt.Errorf("could not read user's theme file(%s), err : %w", themeFile, err)
}
if err = toml.Unmarshal(data, obj); err != nil {
return fmt.Errorf("could not unmarshal user's theme file(%s) : %w", themeFile, err)
}
return nil
}
// LoadAllDefaultConfig : Load all default configurations from embedded superfile_config folder into global
// configurations variables and write theme files if its needed.
func LoadAllDefaultConfig(content embed.FS) {
err := LoadConfigStringGlobals(content)
if err != nil {
slog.Error("Could not load default config from embed FS", "error", err)
return
}
currentThemeVersion, err := os.ReadFile(variable.ThemeFileVersion)
if err != nil && !os.IsNotExist(err) {
slog.Error("Unexpected error reading from file:", "error", err)
return
}View on GitHub (pinned to b72f550bc6)
Solutions
- Validate the TOML with a TOML linter/parser (e.g. taplo) to find the syntax error.
- Diff the file against a working default theme file to find incompatible fields.
- Restore a stock theme file or re-download it.
- Update superfile if the theme schema changed between versions.
Example fix
// before background = '#1e1e2e // missing closing quote // after background = '#1e1e2e'
Defensive patterns
Strategy: validation
Validate before calling
data, err := os.ReadFile(themeFile)
if err != nil { return err }
var probe ThemeType
if err := toml.Unmarshal(data, &probe); err != nil {
return fmt.Errorf("invalid theme TOML in %s: %w", themeFile, err)
} Type guard
func isTomlSyntaxError(err error) bool {
var parseErr toml.ParseError
return errors.As(err, &parseErr)
} Try / catch
if err := common.LoadUserTheme(themeFile, &theme); err != nil {
var parseErr toml.ParseError
if errors.As(err, &parseErr) {
log.Errorf("Theme file %s is not valid TOML (line info: %v)", themeFile, parseErr)
return fallbackTheme()
}
return err
} Prevention
- Validate hand-edited theme files with a TOML linter before deploying.
- Pin theme files to the superfile version that understands their schema.
- Keep a known-good stock theme as a fallback.
- Avoid copy-pasting theme snippets from YAML/JSON into TOML files.
When it happens
Trigger: LoadThemeFile -> LoadUserTheme where the theme file exists but toml.Unmarshal(data, obj) fails: malformed TOML syntax, duplicate keys, or a value with the wrong type for a ThemeType field.
Common situations: Hand-edited theme file with a missing quote or unclosed table; a theme downloaded from the internet written for a different superfile version (schema changed); saving the file with wrong encoding or accidental JSON/YAML content.
Related errors
- could not read user's theme file(%s), err : %w
- error encoding data : %w
- error writing file : %w
- failed to create directory %s: %w
- failed to create file %s: %w
AI-assisted analysis of yorukot/superfile@b72f550bc6 (2026-09-01).
Data as JSON: /api/errors/03d8914b78631f92.
Report an issue: GitHub.