{"record":{"id":"3b9dfcf4342c8f6f","repo":"libnyanpasu/clash-nyanpasu","slug":"invalid-theme-color","errorCode":null,"errorMessage":"Invalid theme color: {}","messagePattern":"Invalid theme color: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/bridge/verge.rs","lineNumber":502,"sourceCode":"fn validate_verge_patch(verge: &IVerge) -> anyhow::Result<()> {\n    if let Some(theme_color) = &verge.theme_color\n        && !theme_color.is_empty()\n        && !legacy_app::is_hex_color(theme_color)\n    {\n        anyhow::bail!(\"Invalid theme color: {}\", theme_color);\n    }\n    Ok(())\n}","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/bridge/verge.rs#L484-L520","documentation":"Validation guard in validate_verge_patch rejecting a verge patch whose theme_color is set, non-empty, and not a valid hex color per legacy_app::is_hex_color. The faulting input is the user-supplied theme_color string inside the IVerge patch; the patch is aborted before any config is applied, so an invalid value never reaches persisted state.","triggerScenarios":"Patching verge config (validate_patch path) with theme_color set to a non-hex string like 'red', 'rgb(255,0,0)', or '#zzz'.","commonSituations":"Importing configs from older versions or third-party tools that stored named/rgb colors, or users typing arbitrary color strings in settings.","solutions":["Convert the value to a hex color string like '#55008f' before patching","Clear theme_color (empty string is allowed) to use the default","Add client-side validation that checks hex format before submitting the patch"],"exampleFix":"// before\npatch.theme_color = 'rgb(85,0,143)'\n// after\npatch.theme_color = '#55008f'","handlingStrategy":"validation","validationCode":"const isHexColor = (s: string) => /^#[0-9a-fA-F]{6}$/.test(s)\nif (patch.theme_color && !isHexColor(patch.theme_color)) {\n  throw new Error('theme_color must be a hex color like #55008f')\n}","typeGuard":"const isHexColor = (v: unknown): v is string =>\n  typeof v === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(v)","tryCatchPattern":"try {\n  await client.patch_app_config(patch)\n} catch (e) {\n  if (String(e).includes('Invalid theme color')) {\n    showToast('Theme color must be in #RRGGBB format')\n  }\n}","preventionTips":["Validate color inputs with a hex regex in the UI before patching","Normalize named/rgb colors to hex before saving","Keep theme_color empty to use the default"],"tags":["validation","config","color"],"backgroundTag":"invalid-config-value","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}