{"record":{"id":"ac0ec0bf73992983","repo":"rocksdanister/lively","slug":"not-lively-zip","errorCode":null,"errorMessage":"Not Lively .zip","messagePattern":"Not Lively \\.zip","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/Lively/Lively.UI.Shared/ViewModels/LibraryViewModel.cs","lineNumber":552,"sourceCode":"                    return AddWallpaper(installDir);\n                }\n                catch (Exception)\n                {\n                    try\n                    {\n                        Directory.Delete(installDir, true);\n                    }\n                    catch { }\n                    throw;\n                }\n                finally\n                {\n                    semaphoreSlimInstallLock.Release();\n                }\n            }\n            else\n            {\n                throw new InvalidOperationException(\"Not Lively .zip\");\n            }\n        }\n\n        public async Task<LibraryModel> AddWallpaperFile(string filePath, bool autoSetWallpaper)\n        {\n            if (FileTypes.IsWallpaperPackageExtension(filePath))\n            {\n                if (FileTypes.IsWallpaperPackage(filePath))\n                {\n                    await semaphoreSlimInstallLock.WaitAsync();\n                    string installDir = null;\n                    try\n                    {\n                        installDir = Path.Combine(userSettings.Settings.WallpaperDir, Constants.CommonPartialPaths.WallpaperInstallDir, Path.GetRandomFileName());\n                        await Task.Run(() => ZipExtract.ZipExtractFile(filePath, installDir, false));\n                        // We do not autoSetWallpaper for .zip\n                        return AddWallpaper(installDir);\n                    }","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/rocksdanister/lively/blob/c1036feb664960722e34bf4309042c247d6a909d/src/Lively/Lively.UI.Shared/ViewModels/LibraryViewModel.cs#L534-L570","documentation":"Thrown by LibraryViewModel.AddWallpaperFile in the else branch when a file has a wallpaper-package extension but fails FileTypes.IsWallpaperPackage — i.e. it looks like a lively archive by name but isn't one by content. InvalidOperationException with a hard-coded English string.","triggerScenarios":"AddWallpaperFile(filePath, autoSetWallpaper) where FileTypes.IsWallpaperPackageExtension(filePath) is true but FileTypes.IsWallpaperPackage(filePath) is false (e.g. extension matches yet the magic/header check fails or LivelyInfo.json is absent).","commonSituations":"User renamed a normal .zip to .lwzip; the package was re-zipped incorrectly so the header/marker is missing; a partially downloaded package; a third-party archive that mimics the extension.","solutions":["Re-export or re-download the wallpaper package from a trusted source.","Inspect the archive to confirm it is a genuine lively package (root LivelyInfo.json).","Validate with FileTypes.IsWallpaperPackage before showing the 'add' affordance, so the user gets an inline error instead of an exception."],"exampleFix":"// before\nelse\n    throw new InvalidOperationException(\"Not Lively .zip\");\n\n// after — use the localized message used elsewhere for consistency\nelse\n    throw new InvalidOperationException(i18n.GetString(\"LivelyExceptionNotLivelyZip\"));","handlingStrategy":"validation","validationCode":"if (!FileTypes.IsWallpaperPackage(filePath))\n{\n    await dialogService.ShowMessageAsync(\"Not a lively wallpaper package.\");\n    return;\n}","typeGuard":"static bool IsAddablePackage(string filePath)\n    => FileTypes.IsWallpaperPackageExtension(filePath) && FileTypes.IsWallpaperPackage(filePath);","tryCatchPattern":"try { await libraryViewModel.AddWallpaperFile(filePath, autoSetWallpaper); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Not Lively .zip\"))\n{ ShowError(\"The file is not a valid lively package.\"); }","preventionTips":["Pre-screen dropped/selected files with FileTypes.IsWallpaperPackage.","Reject renamed ordinary zips at the UI before reaching the view-model.","Re-download packages from trusted sources."],"tags":["wallpaper","zip","validation","file-type"],"backgroundTag":null,"analyzedSha":"c1036feb664960722e34bf4309042c247d6a909d","analyzedAt":"2026-08-13T13:03:12.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}