{"record":{"id":"74fc3d98b5621e87","repo":"Zackriya-Solutions/meetily","slug":"failed-to-serialize-preferences","errorCode":null,"errorMessage":"Failed to serialize preferences: {}","messagePattern":"Failed to serialize preferences: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/recording_preferences.rs","lineNumber":153,"sourceCode":"}\n\n/// Save recording preferences to store\npub async fn save_recording_preferences<R: Runtime>(\n    app: &AppHandle<R>,\n    preferences: &RecordingPreferences,\n) -> Result<()> {\n    info!(\"Saving recording preferences: save_folder={:?}, auto_save={}, format={}, mic={:?}, system={:?}\",\n          preferences.save_folder, preferences.auto_save, preferences.file_format,\n          preferences.preferred_mic_device, preferences.preferred_system_device);\n\n    // Get or create store\n    let store = app\n        .store(\"recording_preferences.json\")\n        .map_err(|e| anyhow::anyhow!(\"Failed to access store: {}\", e))?;\n\n    // Serialize preferences to JSON value\n    let prefs_value = serde_json::to_value(preferences)\n        .map_err(|e| anyhow::anyhow!(\"Failed to serialize preferences: {}\", e))?;\n\n    // Save to store\n    store.set(\"preferences\", prefs_value);\n\n    // Persist to disk\n    store\n        .save()\n        .map_err(|e| anyhow::anyhow!(\"Failed to save store to disk: {}\", e))?;\n\n    info!(\"Successfully persisted recording preferences to disk\");\n\n    // Save backend preference to global config\n    #[cfg(target_os = \"macos\")]\n    if let Some(backend_str) = &preferences.system_audio_backend {\n        if let Some(backend) = AudioCaptureBackend::from_string(backend_str) {\n            info!(\"Setting audio capture backend to: {:?}\", backend);\n            crate::audio::capture::set_current_backend(backend);\n        }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/recording_preferences.rs#L135-L171","documentation":"serde_json::to_value(&preferences) failed while converting RecordingPreferences into a JSON value before writing it to the store. With derive-based Serialize this path is nearly unreachable; it fires only when a field's type or a custom Serialize impl actively produces an error (for example a map with non-string keys, or a manual impl returning Err).","triggerScenarios":"A newly added RecordingPreferences field whose type cannot serialize to JSON (HashMap with non-string key types, a hand-written Serialize with failure branches); a field type changed to one that no longer implements Serialize correctly.","commonSituations":"Struct evolution across app versions; copying in a custom type whose Serialize impl has error paths; Path types containing non-UTF-8 data passed through custom serialization.","solutions":["Read the serde error message - it names the offending field","Ensure every field of RecordingPreferences derives or implements Serialize","Replace HashMap<NonStringKey, _> with string keys or serialize keys explicitly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Startup round-trip: fail fast in debug builds if the prefs struct stops serializing\n#[cfg(debug_assertions)]\n{\n    let probe = serde_json::to_value(RecordingPreferences::default())\n        .expect(\"RecordingPreferences must serialize\");\n    let _back: RecordingPreferences = serde_json::from_value(probe)\n        .expect(\"RecordingPreferences must round-trip\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep RecordingPreferences fully derive(Serialize, Deserialize) - avoid custom impls with error branches","Never use non-string map keys in Serialize structs destined for JSON","Add a serialization round-trip unit test so struct changes fail CI, not users"],"tags":["serde","serialization","json","rust"],"backgroundTag":"serde-serialization-failed","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}