{"record":{"id":"2bad57dca05c7ede","repo":"siyuan-note/siyuan","slug":"invalid-appearance-mode-s","errorCode":null,"errorMessage":"invalid appearance mode: %s","messagePattern":"invalid appearance mode: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/appearance.go","lineNumber":114,"sourceCode":"\t\t\t\t\treturn fmt.Errorf(\"theme [%s] not exists or not available for dark mode\", theme)\n\t\t\t\t}\n\t\t\t\tConf.Appearance.ThemeDark = theme\n\t\t\t}\n\t\t}\n\t}\n\n\tif appearanceMode != \"\" {\n\t\tswitch appearanceMode {\n\t\tcase \"light\":\n\t\t\tConf.Appearance.ModeOS = false\n\t\t\tConf.Appearance.Mode = 0\n\t\tcase \"dark\":\n\t\t\tConf.Appearance.ModeOS = false\n\t\t\tConf.Appearance.Mode = 1\n\t\tcase \"system\":\n\t\t\tConf.Appearance.ModeOS = true\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid appearance mode: %s\", appearanceMode)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc containTheme(name string, themes []*conf.AppearanceTheme) bool {\n\tfor _, t := range themes {\n\t\tif t.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc containIcon(name string, icons []*conf.AppearanceIcon) bool {\n\tfor _, i := range icons {\n\t\tif i.Name == name {\n\t\t\treturn true","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/appearance.go#L96-L132","documentation":"Returned by SetTheme when appearanceMode is non-empty but not one of the accepted literals \"light\", \"dark\", or \"system\". SetTheme switches on these three values to set ModeOS and Mode; any other string (typos, localized values, \"auto\", \"Light\") falls through to the default branch and is rejected.","triggerScenarios":"Calling SetTheme with an appearanceMode such as \"auto\", \"Light\", \"day\", or any non-English/localized word; passing an uppercase variant; trailing whitespace in the value.","commonSituations":"A client sends a localized or capitalized mode string; a typo; whitespace from user input not trimmed; confusion with theme-mode integers (passing \"0\"/\"1\" instead of \"light\"/\"dark\").","solutions":["Pass exactly \"light\", \"dark\", or \"system\" (lowercase, no whitespace).","Trim and lowercase the value before calling SetTheme if it originates from user input.","Pass an empty string to leave the appearance mode unchanged."],"exampleFix":"// before\nmodel.SetTheme(\"daylight\", []int{0}, \"Light \")\n// after\nmode := strings.ToLower(strings.TrimSpace(\"Light \"))\nmodel.SetTheme(\"daylight\", []int{0}, mode)  // \"light\"","handlingStrategy":"validation","validationCode":"switch strings.ToLower(strings.TrimSpace(appearanceMode)) {\ncase \"\", \"light\", \"dark\", \"system\":\ndefault:\n    return fmt.Errorf(\"invalid appearance mode: %s\", appearanceMode)\n}","typeGuard":"func validAppearanceMode(mode string) bool {\n    switch mode {\n    case \"\", \"light\", \"dark\", \"system\": return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Normalize mode input: trim whitespace and lowercase before calling SetTheme.","Pass an empty string to leave the mode unchanged.","Use the canonical literals light/dark/system; avoid localized or capitalized variants."],"tags":["appearance","config","mode","validation","enum"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}