rocksdanister/lively · warning · InvalidOperationException

Not Lively .zip

Error message

Not Lively .zip

What it means

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.

Source

Thrown at src/Lively/Lively.UI.Shared/ViewModels/LibraryViewModel.cs:552

                    return AddWallpaper(installDir);
                }
                catch (Exception)
                {
                    try
                    {
                        Directory.Delete(installDir, true);
                    }
                    catch { }
                    throw;
                }
                finally
                {
                    semaphoreSlimInstallLock.Release();
                }
            }
            else
            {
                throw new InvalidOperationException("Not Lively .zip");
            }
        }

        public async Task<LibraryModel> AddWallpaperFile(string filePath, bool autoSetWallpaper)
        {
            if (FileTypes.IsWallpaperPackageExtension(filePath))
            {
                if (FileTypes.IsWallpaperPackage(filePath))
                {
                    await semaphoreSlimInstallLock.WaitAsync();
                    string installDir = null;
                    try
                    {
                        installDir = Path.Combine(userSettings.Settings.WallpaperDir, Constants.CommonPartialPaths.WallpaperInstallDir, Path.GetRandomFileName());
                        await Task.Run(() => ZipExtract.ZipExtractFile(filePath, installDir, false));
                        // We do not autoSetWallpaper for .zip
                        return AddWallpaper(installDir);
                    }

View on GitHub (pinned to c1036feb66)

Solutions

  1. Re-export or re-download the wallpaper package from a trusted source.
  2. Inspect the archive to confirm it is a genuine lively package (root LivelyInfo.json).
  3. Validate with FileTypes.IsWallpaperPackage before showing the 'add' affordance, so the user gets an inline error instead of an exception.

Example fix

// before
else
    throw new InvalidOperationException("Not Lively .zip");

// after — use the localized message used elsewhere for consistency
else
    throw new InvalidOperationException(i18n.GetString("LivelyExceptionNotLivelyZip"));
Defensive patterns

Strategy: validation

Validate before calling

if (!FileTypes.IsWallpaperPackage(filePath))
{
    await dialogService.ShowMessageAsync("Not a lively wallpaper package.");
    return;
}

Type guard

static bool IsAddablePackage(string filePath)
    => FileTypes.IsWallpaperPackageExtension(filePath) && FileTypes.IsWallpaperPackage(filePath);

Try / catch

try { await libraryViewModel.AddWallpaperFile(filePath, autoSetWallpaper); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Not Lively .zip"))
{ ShowError("The file is not a valid lively package."); }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of rocksdanister/lively@c1036feb66 (2026-08-13). Data as JSON: /api/errors/ac0ec0bf73992983. Report an issue: GitHub.