{"record":{"id":"fc3818c0cf7c30e0","repo":"Universal-Debloater-Alliance/universal-android-debloater-next-generation","slug":"unable-to-write-file","errorCode":null,"errorMessage":"Unable to write file","messagePattern":"Unable to write file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uad-core/src/uad_lists.rs","lineNumber":231,"sourceCode":"                \"https://raw.githubusercontent.com\\\n                    /Universal-Debloater-Alliance\\\n                    /universal-android-debloater\\\n                    /main\\\n                    /resources\\\n                    /assets\\\n                    /{LIST_FNAME}\"\n            ))\n            .call()\n            {\n                Ok(mut data) => {\n                    // https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/discussions/608\n                    let text = data\n                        .body_mut()\n                        .with_config()\n                        .limit(1 << (3 + 10 + 10))\n                        .read_to_string()\n                        .expect(\"remote list is bigger than 8MiB\");\n                    fs::write(cached_uad_lists.clone(), &text).expect(\"Unable to write file\");\n                    let list: PackageHashMap =\n                        serde_json::from_str(&text).expect(\"Unable to parse\");\n                    OperationResult::Ok(list)\n                }\n                Err(e) => {\n                    warn!(\"Could not load remote debloat list: {e}\");\n                    error = true;\n                    OperationResult::Retry(PackageHashMap::new())\n                }\n            }\n        })\n        .unwrap_or_else(|_| get_local_lists())\n    } else {\n        warn!(\"Could not load remote debloat list\");\n        get_local_lists()\n    };\n\n    (if error { Err } else { Ok })(list)","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/blob/64465c850c7ed36329e67165ac08501abffb218e/crates/uad-core/src/uad_lists.rs#L213-L249","documentation":"After successfully downloading the remote debloat list text, load_debloat_lists persists it to the cached lists file with `fs::write(...).expect(\"Unable to write file\")`. If the filesystem write fails for any reason, this panics, aborting the whole load operation even though the download itself succeeded.","triggerScenarios":"Calling load_debloat_lists (via update_lists, list_packages, init_apps_view, etc.) when the cache directory is missing, read-only, or full, or the cached UAD lists file is locked by another process / lacks write permission.","commonSituations":"Read-only config/home directories (flatpak/sandboxed installs, restricted CI users); disk full; CACHE_DIR pointing at a non-writable path after a migration; antivirus or backup tooling holding the file open on Windows.","solutions":["Replace .expect with error propagation: log a warning and continue using the in-memory `text`/`list` even if caching failed.","Ensure the cache directory exists with correct permissions before writing (setup_uad_dir / create_dir_all) and check writability.","Fall back to the previous cached file if the write fails, keeping the app functional.","Free disk space or fix permissions on the UAD cache directory."],"exampleFix":"// before\nfs::write(cached_uad_lists.clone(), &text).expect(\"Unable to write file\");\n// after\nif let Err(e) = fs::write(&cached_uad_lists, &text) {\n    warn!(\"Could not cache debloat list: {e}\");\n}","handlingStrategy":"try-catch","validationCode":"if !cached_uad_lists.parent().map_or(false, |p| p.exists()) {\n    std::fs::create_dir_all(cached_uad_lists.parent().unwrap())?;\n}\nlet writable = std::fs::OpenOptions::new().append(true).open(&cached_uad_lists).is_ok();\nif !writable { eprintln!(\"cache file not writable: {:?}\", cached_uad_lists); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = fs::write(&cached_uad_lists, &text) {\n    warn!(\"caching failed, continuing with in-memory list: {e}\");\n}","preventionTips":["Verify the cache directory exists and is writable before writing.","Never make cache persistence fatal — the data is already in memory.","Watch for read-only/sandboxed install environments (flatpak, snap, CI)."],"tags":["panic","filesystem","io","cache"],"backgroundTag":"file-write-failed","analyzedSha":"64465c850c7ed36329e67165ac08501abffb218e","analyzedAt":"2026-09-12T09:09:23.137Z","contentChangedAt":"2026-09-12T09:09:23.137Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}